3 ms·
In JavaScript it depends on how it is invoked: eval(a) has access to scope variables but x=eval;x(a) does not.
by hdhzy 10y ago
In JavaScript it depends on how it is invoked: eval(a) has access to scope variables but x=eval;x(a) does not.
- Gaelan 10y agoI am surprised that JavaScript can still surprise me.
- hdhzy 10y agoI suggest reading the spec. 5.1 [0] although dated is written in very easy to understand language (well, most parts). After that, fragments like this suddenly make sense: n = 1 /1*"\/\//.test(n + '"//') [0]: https://www.ecma-international.org/ecma-262/5.1/ https://www.ecma-international.org/ecma-262/5.1/
- Gaelan 10y agoMy favorite bit of wat.js is this: [1,2,3] + [4,5,6] // => "1,2,34,5,6" I mean, it makes some degree of logical sense (toString -> concat) but there is no reason that would ever be the intended behavior. As for that expression, meh. You can write intentionally obtuse code in any language. The problem with JS is the behavior that is different from what you'd expect.