Javascript Array first()
method
"use strict";/*from w ww. ja va2 s . c o m*/ //zad3 Array.prototype.first = function () { if (this.length === 0) { throw "Empty string doesn't have first element"; } return this[0]; }; console.log(["a", "b", 3].first()); //console.log([].first());