1

How would I get this in CoffeeScript? This is the JS that I am trying to get :

if (value === undefined) {
  return model.get('isCompleted');
} 

Basically, When I am trying this :

if value is undefined
  model.get 'isCompleted'

I am getting this in the JS :

if (value === void 0) {
  model.get('isCompleted');
}

Is there no way to display "undefined" without :

if value is `undefined`

I somehow don't want to use ``.

user3187254
  • 155
  • 2
  • 9

1 Answers1

3

In case you're not aware of the CoffeeScript existential operator, that makes it real easy to check whether a variable is defined (i.e. it's not undefined or null). If it doesn't matter to you whether value is null or undefined, I'd use that. Use it like so:

if !value?
  model.get 'isCompleted'
aknuds1
  • 65,625
  • 67
  • 195
  • 317