在 Nodejs 中启用 ES6 (harmonie) 版本:
开始吧 ,
Linux 下启用
来源 : http://h3nthanth.com/new/blog/2013/es6-on-nodejs/
Version du nœud: v0.11.6
先来看一看版本 préjudice;):
$ node --v8-options | Grep Harm --Harmony_Typeof (Activer l'harmony Semantics pour typeof) --harmony_scoping (activer l'harmony block-scoping) --harmony_modules (activer les modules Harmony (implique le blocage de blocs)) - Harmony_proxies (activer les symboles harmoniques (aka privés)) - Harmony_proxies (activer Harmony Proxies) - Aka Priva (Activer les collections d'harmonie (ensembles, cartes et cartes faibles)) --harmony_observation (activer l'observation d'objets Harmony (implique des collections d'harmonie) --harmony_typed_arrays (activer les tableaux typiques de l'harmonie) - Armoine_Array_Buffer (for-of)) --harmony_numeric_literals (activer l'harmonie littérales numériques (0o77, 0b11)) --harmony_strings (activer la chaîne harmonielle) --harmony_arrays (activer les arges Harmony) --harmony (activer toutes les fonctionnalités de harmonie (sauf typeof)))
不错 , 我们可以通过 awk 来启用所有的 es6 新特性 , 需要跟 Strict 一起使用
$ node --use-strict $ (node --v8-options | grep dommage | awk '{print $ 1}' | xargs) # es6Windows 下启用 (通用方法 通用方法
来源 : http://stackoverflow.com/questions/13351965/What-does-Node-Harmony-Do
Node - Harmony App.js
看一个例子
作用域
关键字 Soit 可以让我们将变量的作用范围限定在一个代码块中
'utiliser strict'; if (1) {Soit b = 2; console.log (b); //2 }Console.log(ypeof b); //indéfini