0

I have an object which is like:

Object {w74: Object, w100: Object,w12: Object,w3: Object}

I need to eleminate one of them to have

Object {w74: Object, w100: Object,w3: Object}

How can remove this in javascript

2

3 Answers 3

4

Use the delete operator:

var ob = {w74: {number: 1}, w100: {number: 2},w12: {number: 3},w3: {number: 4}};
console.log(ob);
delete ob.w74;
console.log(ob);

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

Comments

1

You can directly delete your value from object by key value

eg.

  var arrChildOptions2 = {
       w74: Object, w100: Object,w12: Object,w3: Object
     };

delete arrChildOptions2.w12;

Comments

0

Use underscore library function called _.pick() http://underscorejs.org/#pick

_.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');
=> {name: 'moe', age: 50}

_.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
  return _.isNumber(value);
});
=> {age: 50}

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.