0

Is there a way to check if a property exists on a model?

var self = model.get("users."+userId);
if (! self.name.firstName){
  //do something
}
msj121
  • 2,812
  • 3
  • 28
  • 55

1 Answers1

0

This seems to work; however, you need to check each property one by one, since going to far down the chain might not exist.

so perhaps:

var self = model.get("users."+userId);
if (!self.name && !self.name.firstName){
  //do something
}
msj121
  • 2,812
  • 3
  • 28
  • 55