Re:5 Things They Told You Not To Use In JavaScript
by rikarends on Tuesday April 24, 2012 @07:02PM
(#3886770)
The reason features like 'with' and callee are being pushed out of JS is because they are a complete nightmare for JS engine optimizations. Doesn't mean they are not useful for certain (hacky) things. Google Dart is a direct response of the V8 team against JS having (among many other things) these kind of constructs. If you want your JS to keep getting faster, try not frustrating the guys that make your crap code faster by advertising these constructs too much. Thank you.
[ Parent
| on HN ]
Re:5 Things They Told You Not To Use In JavaScript
by ben_alman on Tuesday April 24, 2012 @07:19PM
(#3886831)
And this behavior is totally obvious (not)
var id = 123;
function updateOptionalProperty(obj) {
with (obj) {
id = 456;
}
}
updateOptionalProperty({id: 0});
id // 123
updateOptionalProperty({});
id // 456
Re:5 Things They Told You Not To Use In JavaScript
by bmuon on Tuesday April 24, 2012 @11:26PM
(#3887546)
I actually ran into code once that had a variable named "position" (totally common name) and then used "with" on a node's style property to set another style based on the value of this "position" variable. Instant bug. It took me a while to figure out what was going on.