如下,关于javascript中数组的自定义属性,应该怎么理解var ary = ["a", "b", "c"];ary.name = "tom";ary.age = 3;console.log(ary); // ["a", "b", "c", name: "test"]console.log(ary.length); // 3console.log(Array.isArray(ary)); // trueconsole.log(ary.name); // "tom"console.log(ary.age); // 3ary.forEach(function (v) { console.log(v); // 依次打印 a b c});for (var prop in ary) { console.log(ary[prop]); // 依次打印 tom 3}
添加回答
举报
0/150
提交
取消