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

データはオブジェクトの例です。JSON

テストの Ember の方法または JS OO の方法はありますか??

はい、アンダースコアです... ;)

4

1 に答える 1

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);
   },
})
于 2012-07-25T18:11:17.967 に答える