Guest User

Untitled

a guest
May 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //attribute finder by Seb
  2. Array.prototype.hasItemWithAttribute = (attributeName, attributeValue) => !!this.find(item => ''+item[attributeName] === ''+attributeValue);
  3. Array.prototype.getItemWithAttribute = attributeName => !!this.find(item => item[attributeName] ? item : false);
  4. hasItemWithAttribute = (list, attributeName, attributeValue) => !!list.find(item => ''+item[attributeName] === ''+attributeValue);
  5. getItemWithAttribute = (list, attributeName )=> !!list.find(item => item[attributeName] ? item : false);
Add Comment
Please, Sign In to add comment