javascript - Array.prototype.find, what's its spec? -
those have chrome 30.0.1599.14 dev seem gifted of new function:
string(array.prototype.find); // "function find() { [native code] }"
however, haven't found reference addition. tests seems accepts arguments a-la some
, every
, on:
array.some(callback[, thisobject]);
and callback
usual callback function of kind:
function([item[, index[, array]]]) { ... }
the function expected return true
when "right" item
passed, item becomes value returned find
. example:
array.prototype.slice.call(document.getelementsbytagname("*")) .find(function(element) {return element.id === "content";});
it's odd way re-define document.getelementbyid
, except when item isn't found find
returns undefined
instead of null
.
it nice if function accept initial index, or if there dual function lastfind
parses array end.
is there who's seen function , can tell me can find spec?
it ecma script 6. here's html version of es6 spec. here's specific section array.prototype.find()
.
update: also, the chromium bug array.prototype.find implementation.
Comments
Post a Comment