Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //attribute finder by Seb
- Array.prototype.hasItemWithAttribute = (attributeName, attributeValue) => !!this.find(item => ''+item[attributeName] === ''+attributeValue);
- Array.prototype.getItemWithAttribute = attributeName => !!this.find(item => item[attributeName] ? item : false);
- hasItemWithAttribute = (list, attributeName, attributeValue) => !!list.find(item => ''+item[attributeName] === ''+attributeValue);
- getItemWithAttribute = (list, attributeName )=> !!list.find(item => item[attributeName] ? item : false);
Add Comment
Please, Sign In to add comment