Revision: 69926
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 10, 2015 19:33 by Waltem
Initial Code
var ary = ["JavaScript", "Java", "CoffeeScript", "TypeScript"]; ary.some(function (value, index, _ary) { console.log(index + ": " + value); return value === "CoffeeScript"; }); // output: // 0: JavaScript // 1: Java // 2: CoffeeScript ary.every(function(value, index, _ary) { console.log(index + ": " + value); return value.indexOf("Script") > -1; }); // output: // 0: JavaScript // 1: Java
Initial URL
Initial Description
Array.prototype.forEach You can't break forEach. So use "some" or "every". Array.prototype.some some is pretty much the same as forEach but it break when the callback returns true. Array.prototype.every every is almost identical to some except it's expecting false to break the loop.
Initial Title
forEach. How to break?
Initial Tags
array
Initial Language
JavaScript