在 NodeJS 中启用 ES6 (Harmony) 版本:
开始吧 ,
Linux 下启用
来源 : http://h3manth.com/new/blog/2013/es6-on-nodejs/
Versão do nó: v0.11.6
先来看一看版本 Dano;):
$ node --v8-opções | grep harm --harmony_typeof (enable harmony semantics for typeof) --harmony_scoping (enable harmony block scoping) --harmony_modules (enable harmony modules (implies block scoping)) --harmony_symbols (enable harmony symbols (aka private names)) --harmony_proxies (enable harmony proxies) --harmony_collections (enable harmony collections (sets, maps, and weak maps)) --harmony_observation (enable harmony object observation (implies harmony collections) --harmony_typed_arrays (enable harmony typed arrays) --harmony_array_buffer (enable harmony array buffer) --harmony_generators (enable harmony generators) --harmony_iteration (enable harmony iteration (para))--harmony_numeric_literals (Ative Harmony Numéricos Literais (0o77, 0b11))-Harmony_strings (Ativar String de Harmony) --Harmony_arrays (Ativar Matrizes de Harmony)-Harmony (Enable todos os recursos de harmonia (exceto o tipoof))
不错 , 我们可以通过 awk 来启用所有的 es6 新特性 , 需要跟 rigoroso 一起使用
$ node --se-strict $ (node --v8-options | Grep Harm | awk '{print $ 1}' | xargs) #es6Windows 下启用 (通用方法)
来源: http://stackoverflow.com/questions/13351965/what-does-node-harmony-do
Nó -Harmony App.js
看一个例子
作用域
关键字 Vamos 可以让我们将变量的作用范围限定在一个代码块中
'Use Strict'; if (1) {Let b = 2; console.log (b); //2ageConsole.log(Typeof b); //indefinido