Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nestedArray = [['😉'],['😊'],['😇']]
- const nestedCopyWithSpread = [...nestedArray] // The spread operator makes a shallow copy
- nestedArray[0][0] = '😡' // Whoops, a bug
- console.log(...nestedArray) // 😡 😊 😇
- console.log(...nestedCopyWithSpread) // 😡 😊 😇
- // A deep copy would require a library like lodash or Ramda's R.clone() method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement