JavaScript には、あちこちに面白い癖があります。この素晴らしい投稿から抜粋したこの癖を考えてみてください(これを共有してくれた M. Staveley に感謝します)。
var colours = ['red', 'green', 'blue']
// is red really in the array?
console.log(colours.indexOf('red') > -1); // outputs true.
// remove red, it's going out of fashion!
delete colours[colours.indexOf('red')];
console.log(colours.indexOf('red') > -1); // outputs false
console.log(colours.length) // length is still three, remember it's javascript!
最後の行は私を悩ませているものです。この癖は私の好奇心を最大限に引き出します.実際の数にアクセスするためのエレガントな方法はcolours
何ですか?