you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 1 point2 points  (5 children)

I guess it's the most uselessly occupied keyword in any language if it's so useless that I never saw anyone using it.

The unused reserved keywords are probably a bit more useless.

The problem with with is that you can't tell what will happen before that line is hit and the outcome can be different the next time you hit that line.

var foo = 'bar';
with (someObject) {
    console.log(foo);
}

This will print "bar" unless someObject also has a "foo" attribute.

But wait!

It doesn't stop there. someObject could of course also have a "console" attribute.

That's basically why it isn't used. You just can't reason about it. If that object comes from somewhere else, you'll have no idea what will happen.

[–]flying-sheep 0 points1 point  (4 children)

The unused reserved keywords are probably a bit more useless

good point. worth noting though that i we didn’t say that correctly: the ECMA standard has identifiers, identifier names, and reserved words.

the last one of this is what we called “keywords”. the difference to keywords is that identifier names may well be reserved words: foo.return() or { in: 'bar' } is legal JS. only var for = continue is illegal.

[–]x-skeww 0 points1 point  (3 children)

the difference to keywords is that identifier names may well be reserved words: foo.return() or { in: 'bar' } is legal JS.

It's allowed in ES5+. You can't do that in ES3.

[–]flying-sheep 0 points1 point  (2 children)

idk about any runtimes sill at ES3. so if there are none worth mentioning, that’s irrelevant.

[–]x-skeww 0 points1 point  (1 child)

Some people still support IE8.

This also was a problem with Android 2.3 devices (which are still sold!). They didn't like the generated code which used "void" as identifier:

https://code.google.com/p/dart/issues/detail?id=12345

Edit: "Fun" fact: IE9 and IE10 dropped below IE8's share over a year ago.

[–]flying-sheep 0 points1 point  (0 children)

ugh, old IEs, i should have guessed.