Node.js examples for Array:Array Value
Get first or default value from Array
Array.prototype.firstOrDefault = function(predicateFunction) { if (this.length == 0) { return null; }//from ww w . j av a2 s .c o m if (predicateFunction == undefined || predicateFunction == null) { return this[0]; } this.each(function() { if (predicateFunction.call(this)) { return item; } }); return null; };