Hacker News new | ask | show | jobs
by sabas123 2677 days ago
Since this seems such a roundabout way of calling eval, does anyone actually use this?
1 comments

Well usually we want to run code at global scope, and direct eval is an obstacle.

There's workarounds like "(1, eval)", but the most idiomatic way is the Function constructor, which always runs code at global scope. That leads to this pattern:

    var global = (new Function("return this")())
which really is the safest way to get the global object. I know right.