I know you're asking facetiously, but foo.splice(0) is pretty useful because it avoids creating a new object. Useful if you are maintaining multiple references or for memory management.
let a = [1,2,3]
let b = a
b = [] // a is still [1,2,3]
b = a
b.splice(0) // a and b are both [] now
View all comments
6
u/scunliffe Sep 23 '22
TL;DR is the answer just…
foo = [];