Let's say:
Foo.user = Ember.Object.extend({
username:null,
name:null,
loadData:function(data){
_.each(data, function(value, key){
console.log(this.hasOwnProperty(String(key)), key, String(key));
console.log((String(key) in this));
console.log(key in this.__proto__);
console.log(_.has(this, key));
...
});
},
})
Where data is an Object ex. JSON
Is there any Ember way of testing or just a JS OO way??
Yes it is underscore... ;)
Ok, context error, my apologies...poor me.
Foo.user = Ember.Object.extend({
username:null,
name:null,
loadData:function(data){
_.each(data, function(value, key){
console.log(this.hasOwnProperty(String(key)), key, String(key));
console.log((String(key) in this));
console.log(key in this.__proto__);
console.log(_.has(this, key));
...
}, this);
},
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.