@1000ch/array-find 中文文档教程
array-find
Array.prototype.find 的 Polyfill。
Usage
功能上:
var find = require('@1000ch/array-find');
function isPrimary(item, index, array) {
var start = 2;
while (start <= Math.sqrt(number)) {
if (number % start++ < 1) {
return false;
}
}
return (number > 1);
}
console.log(find([4, 5, 8, 10], isPrimary));
// => 5
来自 Array 对象:
require('@1000ch/array-find/shim');
var array = [4, 5, 8, 10];
console.log(array.find(isPrimary));
// => 5
License
MIT:http://1000ch.mit-license.org
array-find
Polyfill for Array.prototype.find.
Usage
Functionally:
var find = require('@1000ch/array-find');
function isPrimary(item, index, array) {
var start = 2;
while (start <= Math.sqrt(number)) {
if (number % start++ < 1) {
return false;
}
}
return (number > 1);
}
console.log(find([4, 5, 8, 10], isPrimary));
// => 5
From Array object:
require('@1000ch/array-find/shim');
var array = [4, 5, 8, 10];
console.log(array.find(isPrimary));
// => 5
License
MIT: http://1000ch.mit-license.org