2012-07-25 198 views
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方式?

是的,它是強調...;)

+0

你想在這裏完成什麼? – hvgotcodes 2012-07-25 17:58:55

+0

只是玩燼。無論如何,在創建對象之前測試道具。 – slothy 2012-07-25 18:12:32

回答

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

那麼這個問題解決了嗎? – 2012-07-25 18:15:31

+0

也許,是否會「擴展」原型? – slothy 2012-07-25 18:25:28

+0

如果這不是你的問題的解決方案,它不應該作爲答案發布。您可以編輯您的原始問題以包含您想要的任何其他信息。如果這*是解決方案,那麼請忽略。 – 2012-07-25 18:39:09