I have an object that looks like this.
{
par1: 'par1value',
par2: 'par2value',
par3: 'par3value'
};
I want to remove the property called par1
and save it separately so it looks like this
var par1 = 'par1value';
{
par2: 'par2value',
par3: 'par3value'
};
Can someone suggest a nice way to do this
Get the property:
var value = obj.par1;
Remove the value from the object:
delete obj.par1;
More detail about delete can be found here.
It has been answered already here: How do I remove a property from a JavaScript object?
basically,
var parobject = {
par1: 'par1value',
par2: 'par2value',
par3: 'par3value'
};
var par1 = object.par1;
delete parobject.par1;
Addition: The delete operator is described in here: https://developer.mozilla.org/en/JavaScript/Reference/operators/special_operators/delete_operator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With