SHARE
TWEET

Untitled

a guest Sep 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### array operation : pop, push, shift, unshift, slice, splice
  2. ```nodejs
  3. > a=[1,2,3,4,5,6,7]
  4. [ 1, 2, 3, 4, 5, 6, 7 ]
  5. > a.pop()
  6. 7
  7. > a
  8. [ 1, 2, 3, 4, 5, 6 ]
  9. > a.shift()
  10. 1
  11. > a
  12. [ 2, 3, 4, 5, 6 ]
  13. > a.unshift(1)
  14. 6
  15. > a
  16. [ 1, 2, 3, 4, 5, 6 ]
  17. > a.push(7)
  18. 7
  19. > a
  20. [ 1, 2, 3, 4, 5, 6, 7 ]
  21. > a.slice(2,4)
  22. [ 3, 4 ]
  23. > a
  24. [ 1, 2, 3, 4, 5, 6, 7 ]
  25. > a.splice(2,4)
  26. [ 3, 4, 5, 6 ]
  27. > a
  28. [ 1, 2, 7 ]
  29. > a.splice(2,0,[3,4,5,6])
  30. []
  31. > a
  32. [ 1, 2, [ 3, 4, 5, 6 ], 7 ]
  33. > a.splice(2,1)
  34. [ [ 3, 4, 5, 6 ] ]
  35. > a
  36. [ 1, 2, 7 ]
  37. > a.splice(2,0,3)
  38. []
  39. > a
  40. [ 1, 2, 3, 7 ]
  41. > a.splice(3,0,4)
  42. []
  43. > a
  44. [ 1, 2, 3, 4, 7 ]
  45. >
  46. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top