我安装了babelsudo cnpm install -g babel-cli
安装成功之后mkdir newproj && cd $_ && touch hehe.js
接着打开hehe.js
编写如下代码
var arr = [];
for(let i=0; i<10; i++) {
arr[i] = function() {
console.log(i);
}
}
for(let i=0; i<10; i++) {
arr[i]();
}
然后运行babel编译babel hehe.js
但是在屏幕上打印出来的代码和我的源代码一样,请问应该怎么解决呢
babel6之后要加上preset才会起作用. 要编译es2015, 应该要安装babel-preset-es2015