I am trying to create a static array. But I found that it can increase the item in the array at run time. How I can achieve static array in JavaScript? Why array is mutable in JavaScript?
var a = [];
//var a = new Array(3);
for (var i = 0; i < 5; i++) {
//a.push(i);
a[i] = i;
}
document.write(a);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…