Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small subset of javascript operations on an array
let myArr = [0, 2, 5]
let arr2 = [1, 6, 7]
// Attach a value to the end of an array
myArr.push(6)
console.log(myArr) // [0, 2, 5, 6]
// Attach a value to the beginning of an array
myArr.unshift(3)
console.log(myArr) // [3, 0, 2, 5, 6]
// Combine 2 arrays
let newArr = myArr.concat(arr2)
console.log(newArr) // [3, 0, 2, 5, 6, 1, 6, 7]
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.