is this part of the native javascript lib? which browser support it?
It's part of the JavaScript 1.5 specification. So it must be supported by major browser.
Not a part of any native JS spec I've ever seen, and some quick Google-fu yields no result either. Not to say it isn't in there somewhere, but I'd guess that if it exists it's not well documented or supported.
Edit: beaten to the punch by Philippe, and apparently my answer is wrong. I'll leave it here for humility's sake, though. ;)
Yes it is part of it. Every browser that supports JavaScript 1.5 supports it (that is all major browsers, or grade A).
However, it is not recommended to use the with statement.
Even though I do agree that it should not be used to just avoid declaring another variable (e.g.)
// BAD use of with is to replace this:
// some.expression.with.lots.of.dots.x = 10;
// some.expression.with.lots.of.dots.y = 20;
// with this:
with (some.expression.with.lots.of.dots) {
x = 10;
y = 20;
}
I do think that it has a reasonable use:
// Acceptable use of with is to close over a variable by value.
var functions = [];
for (var i = 0; i < 5; i++) {
with ({ j: i }) {
functions[i] = function() { return j; };
}
}
The other option for the closure is a nested function, which has its advantages, but I find the debug experience being better if using with.