coding, javascript

CoffeeScript way of checking for undefined

I enjoy CoffeeScripting

There is some learning curve but experienced developer will pick up. There is something i am not a fond of, its the indentation for block and function definition.

Here is something to keep in mind: Checking for a variable existence:

Normal Javascript:

if (!(typeof data !== "undefined" && data !== null)) {

CoffeeScript way (awesome)

if data?

Alternative way (same)

if typeof data isnt "undefined" and data isnt null

Share This:

Leave a Reply