Skip to content

Instantly share code, notes, and snippets.

@alexTitakoff
Last active December 25, 2018 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexTitakoff/9f2cfeacc589e59d02040dfe331824ac to your computer and use it in GitHub Desktop.
Save alexTitakoff/9f2cfeacc589e59d02040dfe331824ac to your computer and use it in GitHub Desktop.
== нахождение объекта в массиве по атрибуту
function findWithAttr(array, attr, value) {
for(var i = 0; i < array.length; i += 1) {
if(array[i][attr] === value) {
return i;
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment