数组添加方法效率区别
var dateS01 = new Date(); var arr = []; for(var i =0; i < 1000000; i++){ arr.push(i); } var dateE01 = new Date(); var dateS02 = new Date(); var arr = []; for(var i =0; i < 1000000; i++){ arr[arr.length] = i; } var dateE02 = new Date(); alert((dateE01 - dateS01) + '\n' + (dateE02 - dateS02))
火狐下的:
chrome下的:
IE6下的:
IE8下的: