Skip to content

Instantly share code, notes, and snippets.

@sp90
Created March 20, 2019 08:18
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 sp90/befcf8da495927c34374c53ddd8281c0 to your computer and use it in GitHub Desktop.
Save sp90/befcf8da495927c34374c53ddd8281c0 to your computer and use it in GitHub Desktop.
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