node.js - Javascript / NodeJS: (() => 0) === (() => 0) -
i'm reading javascript allongé, , in see code supposed return false:
(() => 0) === (() => 0)
when run on commandline (ubuntu 14.04) using nodejs, 3 dots: ...
, after cancel using ctrl-c.
i start node.js following command: nodejs
, not node
. using --harmony
doesn't make difference.
node.js version: v0.10.25
why don't result back? thought using nodejs commandline test utility, maybe not idea?
the simple answer why returns false
because though functions same thing , same, initialized in 2 different memory locations (for objects functions, plain objects, , arrays, strict equality operator ===
checks memory location of object.)
also, if you're going use node.js, have make sure interpreting ecmascript6 (otherwise, () => 0
not valid es5, default node.js).
you can use --harmony
flag:
node --harmony app.js
see question "what node --harmony
do?" more info using es6 in node.js. brief quote top answer:
it seems harmony enables new ecma features in language. reason file won't run without harmony because app.js using non-backward compatible features new ecma standard (like block scoping, proxies, sets, maps, etc.)
to explain why might seeing 3 dots, see this question:
so basically, opened node in interactive terminal, , typed node example.js, trying run if javascript. shows 3 dots because not valid javascript code, , waiting type more code might make valid.
the above output. ran in terminal (using 0.12.21
):
> $ node --harmony > (() => 0) === (() => 0) > false
Comments
Post a Comment