Javascript Keyword "With"
Why dont people use "with" more often in javascript? Is it just not helpful?

What do you mean?

It's not recommended and confusing


You use "with" keyword for the context manager.


In javascript, "with" is confusing and ambiguous. I don't know about other languages, but in Visual Basic, there is an extremely clear of the context and which variables you're requesting from the context. In JS, you have something like this:

with (employee) {
     ID = 1;
     name = "John";

It's not clear whether you're attributing to or some name variable outside of the block scope. In Visual Basic, this is solved in a genius way. It requires a dot to "search" on the context variable and there's no ambiguity.

With employee
     .ID = 1
     .name = "John"
End With

It's especially telling that JS supersets like TypeScript don't even allow you to use `with`, even if you're using it to access statically typed properties on an object. MDN has a good writeup on it:

Registered Members Only

You need to be a registered member to see more on RE: Javascript Keyword "With".
Login or Sign up to get access to a huge variety of top quality leaks.