A Strong Mode for JavaScript
docs.google.com
A Strong Mode for JavaScript
1–10 of 45 posts
Re: A Strong Mode for JavaScript
#2What if I want a variable?!
Re: A Strong Mode for JavaScript
#3> It is a SyntaxError to use the keyword 'var' What if I want a variable?!
Re: A Strong Mode for JavaScript
#4 It is a SyntaxError to use the identifier ‘eval’.
SyntaxError? "use strong"; should probably do something like:
let eval = void 0;
rather than making eval a SyntaxError.Re: A Strong Mode for JavaScript
#5It is a SyntaxError to use the identifier ‘eval’. SyntaxError? "use strong"; should probably do something like: let eval = void 0; rather than making eval a SyntaxError.
Re: A Strong Mode for JavaScript
#6> It is a SyntaxError to use the keyword 'var' What if I want a variable?!
use `let ` or `const `. there's no need to use `var` in ES6+, ever.
Re: A Strong Mode for JavaScript
#7It is a SyntaxError to use the identifier ‘eval’. SyntaxError? "use strong"; should probably do something like: let eval = void 0; rather than making eval a SyntaxError.
Making it a syntax error means code will not fail quietly. This should help transition code to Strong mode.
Re: A Strong Mode for JavaScript
#8Earlier quoted context omitted.
use `let ` or `const `. there's no need to use `var` in ES6+, ever.
But we're going to keep it around, aren't we? Because we can always add features but we can't really remove them. It feels like JS is getting cruftier. Would it be better if var already worked like let? Sure. Will JS be better with two slightly different ways of scoping a variable, one of which you really shouldn't use? Doesn't seem like it. One more thing to explain to newcomers.
Re: A Strong Mode for JavaScript
#9 In strong code, accessing objects (strong or not) throws on missing properties.
New object properties have to be defined explicitly and cannot be removed
from strong objects.
To me, this seems to break a fundamental aspect of the language. I've found it very acceptable to be able to define an object literal property "on the fly." However, with strong mode trying to make the language friendlier to eventually being more statically typed, I see the necessity. It just boggles my dynamically typed mind :-)Re: A Strong Mode for JavaScript
#10I think I like most of what this document proposes except for the following: In strong code, accessing objects (strong or not) throws on missing properties. New object properties have to be defined explicitly and cannot be removed from strong objects. To me, this seems to break a fundamental aspect of the language. I've found it very acceptable to be able to define an object literal property "on the fly." However, wi…
foo = bar.x || 3;
rather than foo = bar.hasOwnProperty('x') ? bar.x : 3;
is nice.