Skip to content

Instantly share code, notes, and snippets.

@enricodeleo
Created November 30, 2015 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricodeleo/60ed932644966041aeac to your computer and use it in GitHub Desktop.
Save enricodeleo/60ed932644966041aeac to your computer and use it in GitHub Desktop.
Extend an Array appending elements of another Array in Javascript
// Shorthand function
Array.prototype.append = function(array) {
this.push.apply(this, array)
}
// Example
var a = [1,2];
var b = [3,4];
a.append(b); // 'a' bacames [ 1, 2, 3, 4 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment