Created
July 21, 2016 17:53
-
-
Save AbdallaZaki/102ca77347b95260cbcd43f90adc0d2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.unShift = function (){ | |
let newArray = [...arguments], i = 0, len = this.length , newArrLength=newArray.length; | |
for(i; i < len; i++){ | |
newArray[newArrLength+i] = this[i]; | |
} | |
return newArray; | |
} | |
let arr =[1,2]; | |
console.log(arr.unShift(4,5,6)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment