Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はちょうどこのjavascriptスニペットに出くわしました:
myArray.length--;
それは正確に何をしますか?
これにより、配列の最後の項目が削除されます。
var myArray = [1, 2, 3]; myArray.length--; alert(myArray);
出力は次のとおりです。
[1, 2]
簡単な実験では、配列の最後の要素を切り落とすことが示されています。
> var a = [1, 2, 3]; => undefined > a => [1, 2, 3] > a.length-- => 3 > a => [1, 2]