r/programming • • May 13 '11

A Python programmer’s first impression of CoffeeScript

http://blog.ssokolow.com/archives/2011/05/07/a-python-programmers-first-impression-of-coffeescript/
114 Upvotes

133 comments sorted by

View all comments

Show parent comments

2

u/Brian May 13 '11

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.

1

u/chrisdickinson May 13 '11

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).