揮発性のメモ2

知識をメモ書きしておく

配列の

var list = [];
list[0] = "hello";
list[10] = "world";

console.log( list.length );     // 11
console.log( typeof(list[3]) ); // undefined

// ループ
for(var i=0; i<list.length; i++){
    if(list[i]===undefined) continue;

    console.log(list[i]);
}

JavaScriptの配列も添え字は飛び飛びに出来る。
.lengthは配列の要素数ではなく一番大きい添え字の次の数字になる。

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy