freecodecamp.cn
freecodecamp.cn copied to clipboard
使用 for 循环把从 1 到 5 添加进 myArray 中。 求助如下写法
var myArray = []; for(var i=1;i<6;i++){ //myArray.push(i); /// 标准答案 myArray.unshift(i); ///此处也是按照1到5 加入到数组了。 运行不通过 }
@KaapoMarcus https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift