Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
mirekrusin
· 3y ago · 0 comments
let top5 = Array(5).fill({ idx: 0, count: 0, });
...this kind of code is nice source of bugs in js.
Comments
[–]
lib-dev
3y ago
How?
[–]
fyzix
3y ago
Because it uses the same object for all items in the array. Luckily, they are just placeholders and aren't being mutated.
[–]
lib-dev
3y ago
Ah interesting. I see it now. Thanks for the reply.