2

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?

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

You can delete it:

delete multi.a

Comments

0
var a = [],b = [],c = [],d = [];
var multi = {
   a: a, b: b, c: c, d: d
};
delete multi.a;
console.log(multi);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.