To enable the ES6 (harmony) version in Nodejs:
Let's go
Linux Enabled
Source: http://h3manth.com/new/blog/2013/es6-on-nodejs/
Node version:v0.11.6
First look at the version of harm;):
$ node--v8-options | 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 (a.k.a. Private names))--harmony_proxies (Enable Harmony proxies)--harmony_col Lections (Enable harmony collections (sets, maps, and weak maps))--harmony_observation (Enable Harmony object Observatio N (implies Harmony Collections)--harmony_typed_arrays (Enable harmony typed arrays)--harmony_array_buffer (Enable harm ony array buffer)--harmony_generators (Enable harmony Generators)--harmony_iteration (Enable harmony iteration (for-of
)--harmony_numeric_literals (Enable harmony Numeric literals (0o77, 0B11))--harmony_strings (Enable harmony String) --harmony_arrays (Enable harmony arrays)--harmony (Enable all harmony features (except typeof))
Yes, we can use awk to enable all the ES6 new features that need to be used with strict
$ node--use-strict $ (Node--v8-options | grep harm | awk ' {print} ' | xargs) #ES6
Enabled under Windows (Common method)
Source: http://stackoverflow.com/questions/13351965/what-does-node-harmony-do
Look at an example
Scope
The keyword let lets you limit the scope of a variable to a block of code
' Use strict ';
if (1) {let
b = 2;
Console.log (b); 2
}
Console.log (typeof b);//undefined