测试ember对象中的属性

时间:2012-07-25 17:43:07

标签: javascript ember.js

让我们说:

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));
            ...
        });
    },
})

数据是对象ex。 JSON

是否有任何Ember测试方式或只是JS OO方式?

是的,它是下划线......;)

1 个答案:

答案 0 :(得分:0)

好的,背景错误,道歉......我很糟糕。

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);
   },
})
相关问题