Is Meteor in strict mode?

Is Meteor in strict mode? I believe it is, because of the behavior of this code:

let d = true;

if (d) {
  const wow = 'wow!';

  console.log(wow);
}
console.log('again:', wow);

And I get wow is not defined for the second console.log statement, but const is only block-scoped in strict mode.

Source for that statement? I’m pretty sure both let and const are block scoped no matter what in ES2015, and don’t exist outside their scope.

Try it yourself. Paste the above code into tst.js and run node tst.js. One small change, change this line:

let d = true;

to:

d = true;

You’ll see ‘wow’ printed twice. Then add 'use strict'; to the top of the file, change the first line to let d = true and run again. You’ll get an error.

I think you are mixing a lot of different issues here. “let” and “const” are new definitions from the ES2015 version of javascript/ecmascript, and they work like they are supposed to in meteor because meteor by default includes an ES2015 transpiler.

Node however does not include ES2015 syntax, and uses an old version of const that wasn’t much used, unless you actually compile your node code using something like Babel. “let” won’t work at all without it.

You could also easily check for “automatic” strict mode by just declaring a variable like you did:
d = true;
This would throw “d is not defined” error because neither var nor a global d was specified anywhere.
So no, meteor is not in strict mode.