On 30 January 2013 18:00, Andrea Giammarchi <[email protected]> wrote:
> let me rephrase ...
>
> putting `with(this){` before any build process/inlined library and `}` at
> the end of all concatenated files **nothing** is strict anymore ^_^
>
> function isStrict() {"use strict";
> return this;
> }
>
> isStrict(); // undefined
>
> now, wraping the whole thing inside a with statement
>
> with(this){
> function isStrict() {"use strict";
> return this;
> }
> alert(isStrict()); // global object
> }
>
> forget the Function hack, there is no library able to ensure itself to be
> executed in strict mode.
> Using the width statement around any code makes it not strict.
That is, er, balls, of course. All that happens here is that inside
the 'with', a call to a _toplevel_ function like 'isStrict()' becomes
'this.isStrict()', and so receives the global object. That does not
otherwise change strictness, however. Try:
with(this) {
function isStrict() { "use strict"; var x; delete x; }
alert(isStrict());
}
for example. Moreover, calls to functions not resolving to global
definitions are completely unaffected, so are calls using 'call' or
'apply':
with(this) {
function isStrict() { "use strict"; return this; };
function call(f) { f() };
alert(call(isStrict)); // undefined
alert(isStrict.call()); // undefined
}
Both calls would return window in sloppy mode.
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss