Wednesday, April 5, 2017

Array.prototype.find()

This is "primative" default JS way to do some searching in a collection, primative in comparsion to underscore.js or TypeScript acrobatics of this nature. This has the following example which will pick out just the 130:

function isBigEnough(element) {
   return element >= 15;
}
[12, 5, 8, 130, 44].find(isBigEnough);

No comments:

Post a Comment