This came out of disabling "use strict"; everywhere thread
https://mail.mozilla.org/pipermail/es-discuss/2013-January/028511.html
After a better analysis, I have realized it is possible to simulate the
monocle mustache in ES5 via "use strict";
Any thought on this, appreciated.
function With(o) {
return function (f) {
return Function(
"with(this){return(" + ("" + f).replace(
"{", "{'use strict';"
) + ").call(this)}"
).call(o);
};
}
With({test: 123})(function () {
alert(test); // 123
outer = 456; // throws outer is not defined
});
alert(With({test: 123})(function () {
return test;
}));
br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130130/807a73aa/attachment.html>
This came out of disabling
"use strict";
everywhere thread esdiscuss/2013-January/028511After a better analysis, I have realized it is possible to simulate the monocle mustache in ES5 via
"use strict";
Any thought on this, appreciated.
function With(o) { return function (f) { return Function( "with(this){return(" + ("" + f).replace( "{", "{'use strict';" ) + ").call(this)}" ).call(o); }; } With({test: 123})(function () { alert(test); // 123 outer = 456; // throws outer is not defined }); alert(With({test: 123})(function () { return test; }));