DEV Community

loading...

Discussion on: 8 neat Javascript tricks you didn't know in 4 minutes.

Collapse
destroyer22719 profile image
Nathan Cai

but it still kinda achieves the exact same thing.

Thread Thread
jonrandy profile image
Jon Randy

Not really. If you have another reference to the original array, and you use this method to 'empty' it - stuff is going to break as the other reference will still contain the unemptied array

Thread Thread
blessingartcreator profile image
Blessing Hirwa Author

Thanks for the support Nathan.

Thread Thread
blessingartcreator profile image
Blessing Hirwa Author

I've never met that kind of error but I'll try it in the future. Thanks for the assistance though.

Thread Thread
blessingartcreator profile image
Blessing Hirwa Author

I've never met that kind of error but I'll try it in the future. Thanks for the assistance though.

Thread Thread
industral profile image
Alex Ivasyuv

var a = [1, 2, 3]
var b = a;
a = [];
console.log(b); // [1, 2, 3]

Some comments have been hidden by the post's author - find out more