Javascript 如何从Ext对象中删除属性?
如何从Ext对象中删除属性?例如:Javascript 如何从Ext对象中删除属性?,javascript,extjs,extjs4,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('Cla
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 ?
*/
是否有特殊方法执行此操作?请删除属性的值,而不是删除属性
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
如果您使用console.log(book),您会得到什么?为什么对个人实例使用
book
?无论如何,删除对象上的属性从来都不是一个好主意。由于实例不能共享相同的隐藏类(至少在V8中),因此它会使代码运行变慢。我相信Ext使用了Object.defineProperty
来定义对象属性。默认情况下,以这种方式定义的属性是不可配置的,这意味着不能删除它们,也不能更改描述符。