Lately I have been watching a really good series on the fundamentals of JavaScript from mpj. Here are my notes.
Because JS is a function based languages, functions play a much larger role in JS then they do in other languages. They are treated like variables and passed around.
In this case Array.prototype.filter() returns a new array based on whether the predicate returns true or false for each element of the array.
var words = ["spray", "limit", "elite", "exuberant", "destruction", "present"]; var longWords = words.filter(function(word){ return word.length > 6; });
E6 version
const words = ["spray", "limit", "elite", "exuberant", "destruction", "present"]; let longWords = words.filter(word => word.length > 6);
Leave a Reply