Tuesday, May 1, 2018

.find in TypeScript/JavaScript is kinda like .filter only it will only return the first match and not any array of things.

In this case 18 is returned. ...In TypeScript:

var ages = [3, 10, 18, 20];
let whatever = ages.find(x => x > 17);
alert(whatever);

 
 

In JavaScript:

var ages = [3, 10, 18, 20];
var whatever = ages.find(function (x) { return x > 17; });
alert(whatever);

No comments:

Post a Comment