JSFiddle - React, Tailwind, and code Playground
by kentaromiura
JavaScript
// @license WTFPL
Array.prototype.search = function (w) {
return function(a, t) {
var r = {f:a, c:t, r:r};
this.some(w, r);
return r.r;
};
}(function(f, u, c, k) {
k = this;
if (k.f.call(k.c, f, u, c)) {
k.r = f;
return !0;
}
});
// @example
var o = [8,7,6,0,1,2,3].search(function (v) {
return v < 4;
});
if (o !== undefined) {
// do stuff
// o === 1 in this case
alert(o)
}