You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -38,26 +38,26 @@ The idea is that this is roughly equivallent to:
38
38
39
39
```js
40
40
with (obj) {
41
-
src
41
+
src;
42
42
}
43
43
```
44
44
45
-
There are a few differences though. For starters, assignments to variables will always remain contained within the with block.
45
+
There are a few differences though. For starters, assignments to variables will always remain contained within the with block.
46
46
47
47
e.g.
48
48
49
49
```js
50
-
var foo ='foo'
50
+
var foo ='foo';
51
51
with ({}) {
52
-
foo ='bar'
52
+
foo ='bar';
53
53
}
54
-
assert(foo ==='bar')// => This fails for compile time with but passes for native with
54
+
assert(foo ==='bar'); // => This fails for compile time with but passes for native with
55
55
56
-
var obj = {foo:'foo'}
56
+
var obj = {foo:'foo'};
57
57
with ({}) {
58
-
foo ='bar'
58
+
foo ='bar';
59
59
}
60
-
assert(obj.foo==='bar')// => This fails for compile time with but passes for native with
60
+
assert(obj.foo==='bar'); // => This fails for compile time with but passes for native with
61
61
```
62
62
63
63
It also makes everything be declared, so you can always do:
@@ -72,16 +72,16 @@ instead of
72
72
if (typeof foo ==='undefined')
73
73
```
74
74
75
-
This is not the case if foo is in `exclude`. If a variable is excluded, we ignore it entirely. This is useful if you know a variable will be global as it can lead to efficiency improvements.
75
+
This is not the case if foo is in `exclude`. If a variable is excluded, we ignore it entirely. This is useful if you know a variable will be global as it can lead to efficiency improvements.
76
76
77
77
It is also safe to use in strict mode (unlike `with`) and it minifies properly (`with` disables virtually all minification).
78
78
79
79
#### Parsing Errors
80
80
81
-
with internally uses babylon to parse code passed to `addWith`. If babylon throws an error, probably due to a syntax error, `addWith` returns an error wrapping the babylon error, so you can
82
-
retrieve location information. `error.component` is `"src"` if the error is in the body or `"obj"` if it's in the object part of the with expression.`error.babylonError` is
81
+
with internally uses babylon to parse code passed to `addWith`. If babylon throws an error, probably due to a syntax error, `addWith` returns an error wrapping the babylon error, so you can
82
+
retrieve location information. `error.component` is `"src"` if the error is in the body or `"obj"` if it's in the object part of the with expression. `error.babylonError` is
0 commit comments