Every line of 'jquery find object in array by property value' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
7 export function findObject (array, property, value) { 8 for (let i = 0; i < array.length; i++) { 9 if (array[i][property] === value) { 10 return array[i] 11 } 12 } 13 14 return null 15 }
191 function findObjByProperty (array, propName, value) { 192 for (let i = 0; i < array.length; i++) { 193 if (array[i][propName] === value) { 194 return array[i]; 195 } 196 } 197 return null; 198 }
60 function find(array, byProperty, condition) { 61 if (!array || array.length === 0) { 62 return; 63 } 64 65 var i = array.length - 1, 66 result = byProperty ? array[i][byProperty] : array[i]; 67 if (byProperty) { 68 while (i--) { 69 if (condition(array[i][byProperty], result)) { 70 result = array[i][byProperty]; 71 } 72 } 73 } 74 else { 75 while (i--) { 76 if (condition(array[i], result)) { 77 result = array[i]; 78 } 79 } 80 } 81 return result; 82 }
58 function findBy(arr, prop, val) { 59 return arr[findIndexBy(arr, prop, val)] 60 }
39 function findInArray(arr, propName, propValue) { 40 for (var i = 0; i < arr.length; i++) 41 if (arr[i][propName] == propValue) 42 return arr[i]; 43 44 // will return undefined if not found; you could return a default instead 45 }
387 function findObject(list, name, key) { 388 for (const obj of list) { 389 if (obj.name === name) { 390 if (obj[key]) { 391 return obj[key]; 392 } 393 return obj; 394 } 395 } 396 return null; 397 }
55 function findByAttr (array, attr, value) { 56 return array.find(i => i.getAttribute(attr) === value) 57 }
101 function propertyArray(object, key) { 102 return object != null ? object[key] : null; 103 }
101 export function getProperty(propertyName: string, object: T) { 102 let parts = propertyName.split('.'), 103 length = parts.length, 104 i; 105 106 for (i = 0; i < length; i++) { 107 object = object[parts[i]]; 108 } 109 110 return object; 111 }
96 value: function findAllInObject(object, valueOBj, isMulti) { 97 98 for (var objKey in object) { 99 this.performSearch(object[objKey], valueOBj, object[objKey]); 100 if (!isMulti && this.results.length == 1) { 101 return this.results; 102 } 103 } 104 105 while (this.objects.length !== 0) { 106 var objRef = this.objects.pop(); 107 this.performSearch(objRef._obj, valueOBj, objRef.parent); 108 if (!isMulti && this.results.length == 1) { 109 return this.results; 110 } 111 } 112 113 return this.results; 114 }