Reputation: 2815
How we can remove an array entry from :
var a = [],b = [],c = [],d = [];
var multi = {
a: a, b: b, c: c, d: d
};
Means if i want to remove a
array from multi . What should i do?
Upvotes: 2
Views: 92
Reputation: 9080
Use delete
keyword:
delete multi.a
Example:
var a = [], b = [], c = [], d = [];
var multi = { a: a, b: b, c: c, d: d };
delete multi.a;
console.log(multi);
Result:
Object
b: Array[0]
c: Array[0]
d: Array[0]
Docs:
The delete operator removes a property from an object.
Upvotes: 1
Reputation: 160953
var a = [],b = [],c = [],d = [];
var multi = {
a: a, b: b, c: c, d: d
};
delete multi.a;
console.log(multi);
Upvotes: 0
Reputation: 944430
To remove a property of an object, delete
it.
delete multi.a
It doesn't matter what the value of the property is (it can be an array or anything else).
The variable a
will still contain a reference to the same array though. If you want to get rid of it entirely, you have to overwrite that variable or allow it to fall out of scope.
Upvotes: 1