弗雷奇。如何打破?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了弗雷奇。如何打破?相关的知识,希望对你有一定的参考价值。
Array.prototype.forEachYou 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.
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
以上是关于弗雷奇。如何打破?的主要内容,如果未能解决你的问题,请参考以下文章