Javascript Array double()
Array.prototype.double = function() { var newArray = []; // inside this function, "this" refers to the array for (var i = 0, length = this.length; i < length; i++) { newArray.push(this[i]);/*from www. j a v a2 s . c om*/ newArray.push(this[i]); } alert(newArray); return newArray; }; var exampleArray = new Array(1, 2, 3); // inherits all the properties of Array.prototype //exampleArray.double();