News for hackers. Stuff that matters.
Re:A spreadsheet in fewer than 30 lines of JavaScript, no li... by curveship on Wednesday November 13, 2013 @02:46PM (#6727922)
No, unfortunately. If a reference isn't found in your context object, it falls through to the ambient namespace. So say you run ...

    context = { foo: 1, bar: 2 };

    with (context) {
        foo = 2;
        bar = 3;
    }
That will probably do what you expect. But now say you run it where context is just ...

    context = { foo: 1 };

    with (context) {
        foo = 2;
        bar = 3;
    }
... you might think this would add a 'bar' property to your context object, but in fact it creates a global variable bar. Whoops!

In short, 'with' is pointy on both ends.

Re:A spreadsheet in fewer than 30 lines of JavaScript, no li... by agumonkey on Wednesday November 13, 2013 @03:04PM (#6728062)
Oh yeah, `with` is dangerous.