定义数组
var ary1 = new Array("a","b","c");
var ary2 = ["a","b"];
增删改
ary1.push("1");
遍历数组
for(var i = 0;i < ary.length; i++){
console.log(ary[i]);
}
for ( var index in ary) {
console.log(ary[index]);
}
ary.forEach(function(e, i) {
console.log(e + i);
});
if (!Array.prototype.forEach){
Array.prototype.forEach = function(fun ){
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (var i = 0; i < len; i++){
if (i in this)
fun.call(thisp, this[i], i, this);
}
};
}
}