Skip to main content
tidy up
Source Link
Andrew
  • 20.4k
  • 13
  • 110
  • 122

Just improvedMade the fastestbest/bestfastest part of this answer to be more re-usable/clear & clear:

function getElByPropVal(arrmyArray, prop, val){
    for (var i = 0, length = arrmyArray.length; i < length; i++) {
        if (arr[i][prop]myArray[i][prop] == val){
            return arr[i];myArray[i];
        }
    }
}

Just improved the fastest/best part of this answer to be more re-usable/clear:

function getElByPropVal(arr, prop, val){
    for (var i = 0, length = arr.length; i < length; i++) {
        if (arr[i][prop] == val){
            return arr[i];
        }
    }
}

Made the best/fastest part of this answer more re-usable & clear:

function getElByPropVal(myArray, prop, val){
    for (var i = 0, length = myArray.length; i < length; i++) {
        if (myArray[i][prop] == val){
            return myArray[i];
        }
    }
}
Source Link
Andrew
  • 20.4k
  • 13
  • 110
  • 122

Just improved the fastest/best part of this answer to be more re-usable/clear:

function getElByPropVal(arr, prop, val){
    for (var i = 0, length = arr.length; i < length; i++) {
        if (arr[i][prop] == val){
            return arr[i];
        }
    }
}