Array subscript

1, number as a subscript

2, an array of strings as a subscript [also an object itself, the string is strong property of the object, length of the array itself does not change]

var arr1 = new Array();
    arr1['name'] = "xhaja";
    arr1['age'] = 34
    for(var key in arr1) {
        console.log(key)         //name , age
        console.log(arr1[key])   // xhaja , 34
}
console.log(arr1.length) // 结果为0

Guess you like

Origin www.cnblogs.com/yuyedaocao/p/12046317.html