簡體   English   中英

試驗在余燼對象中的屬性

[英]test for a property in ember object

比方說:

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方法?

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

好吧,上下文錯誤,我的道歉...可憐的我。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM