Search code examples
derbyjs

Check if model contains key derbyjs


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
}

Solution

  • 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
    }