all()
<script>
Array.prototype._each = function(iterator){
for(var i=0, l=this.length; i<l; i++){
iterator(this[i]);
}
};
Array.prototype.each = function(iterator){
var index = 0;
try{
this._each(function(v){
iterator(v, index++);
});
} catch(e){
if(e != $break) throw e;
}
};
Array.prototype.all = function(iterator){
var rs = true;
this.each(function(v, k){
rs = rs && !!iterator(v, k);
if(!rs) throw $break;
});
return rs;
}
var $break = {};
var kekka = [1, 2, 3, 4].all(function(v, k){
return (typeof(v) === 'number');
});
console.log(kekka);
</script>