Javascript Array first(num)
Array.prototype.first = function (num) { if (num !== undefined) { return this.slice(0, num); }//from ww w . j a va 2 s. c om return this[0]; }; })();