original = [1, 2, 3]
copy = original.slice(0)
console.log original # [ 1, 2, 3 ]
console.log copy # [ 1, 2, 3 ]
console.log original is copy # false
More than 5 years have passed since last update.
Shallow copy for Array in JavaScript
Posted at
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
22