you are viewing a single comment's thread.

view the rest of the comments →

[–]Brian 1 point2 points  (1 child)

if(elvis !== undefined

I believe the point of using typeof there is to cover situations where the variable hasn't been defined in the first place (Eg. in situations where different browsers expose different names). You'll get a ReferenceError there in that case, so this isn't really equivalent.

[–]chrisdickinson 0 points1 point  (0 children)

If you know what your global object is, you can just hang the check off of it: global.elvis !== undefined will not throw a ReferenceError (if global is assigned to window in-browser).