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

asked Jul 6, 2016 at 11:05
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);

answered Jul 6, 2016 at 11:07
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;
answered Jul 6, 2016 at 12:09

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}
answered Jul 6, 2016 at 11:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.