Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法检查模型上是否存在属性?
var self = model.get("users."+userId); if (! self.name.firstName){ //do something }
这似乎有效;但是,您需要一一检查每个属性,因为可能不存在深入到链条的下游。
所以也许:
var self = model.get("users."+userId); if (!self.name && !self.name.firstName){ //do something }