Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.