babel-node 测试 let 关键子
代码如下: index.js
"use strict";
console.log('a = ', a);
try {
console.log('b = ', b);
}catch(e) {
console.log(e);
}
var a = 1;
let b = 2;
我用node index.js
(node 版本为 4.4.0), 结果为:
a = undefined
[ReferenceError: b is not defined]
但如果我用 babel-node index
(babel-node 版本为 6.6.5), 结果却是:
a = undefined
b = undefined
.babelrc 文件配置为:
{
"presets": [
"es2015",
"react"
],
"plugins": [
"add-module-exports"
]
}
为什么使用babel-node 不抛出异常呢?