Created
June 27, 2011 07:52
-
-
Save nazt/1048462 to your computer and use it in GitHub Desktop.
Array.prototype.push
This file contains hidden or 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
| // Appends the arguments to the end of the array and returns the new | |
| // length of the array. See ECMA-262, section 15.4.4.7. | |
| function ArrayPush() { | |
| if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | |
| throw MakeTypeError("called_on_null_or_undefined", | |
| ["Array.prototype.push"]); | |
| } | |
| var n = TO_UINT32(this.length); | |
| var m = %_ArgumentsLength(); | |
| for (var i = 0; i < m; i++) { | |
| this[i+n] = %_Arguments(i); | |
| } | |
| this.length = n + m; | |
| return this.length; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment