Javascript Array extend(array)
// takes an array and add it's eliments to the end of this array // a = [1, 2, 3]//from www . ja va 2 s . co m // b = [4, 5, 6, 7] // a.extend(b) // a => [1, 2, 3, 4, 5, 6, 7] Array.prototype.extend = function(array) { this.push.apply(this, array) } // use native index of to test for inclution Array.prototype.inArray = function(val) { return (this.indexOf(val) > -1) }
Array.prototype.extend = function(array){ for (var j = array.length-1; j >= 0; j--) this.unshift(array[j]); return this;/*from w w w. j a v a 2 s . co m*/ }; Function.prototype.bind = function(bind,args){ var self = this; var options = args; return function(){ var args = (options != undefined) ? options.extend(arguments) : arguments; return (function(){ return self.apply(bind || null, args); })(); } };