如何从Ext对象中删除属性?

时间:2014-08-13 18:57:42

标签: javascript extjs extjs4

如何从Ext对象中删除属性?例如:

Ext.define('Classes.Person', {status:'load',
    config: {
            name: 'Eugene',
            surname : 'Popov'
    },
    constructor: function(config) {
        this.initConfig(config);
    }
  });

var book = Ext.create('Classes.Person') 
/*
console.log(book.status)//load 
console.log( book.surname  )//Popov 
delete book.status
delete book.surname;
 console.log( book.surname  )//Popov 
 console.log(book.status)//load  How delete property ? 
 */

有没有特殊方法可以这样做?

1 个答案:

答案 0 :(得分:2)

不删除属性,而是删除属性的值

console.log(book.status)//load 
console.log( book.surname  )//Popov 
book.status = undefined; //remove the existing value
book.surname = undefined;
console.log( book.surname  )//undefined 
console.log(book.status)//undefined