Michael Phelps
Michael Phelps

Reputation: 3601

How to delete a property from an Ext object?

How to delete a property from an Ext object ? For example :

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 ? 
 */

Is there a special method to do so?

Upvotes: 2

Views: 1396

Answers (2)

Marcin
Marcin

Reputation: 589

To delete a property from an object in ExtJs just use 'delete' command, like in example:

delete book.status;

It deletes 'status' property from 'book' object. I just checked it on my side and works perfectly.

Upvotes: 0

newmount
newmount

Reputation: 1951

Instead of deleting property, delete the value of the 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

Upvotes: 2

Related Questions