Clone object only with some params
I want validate a Object and maybe this object can have extra params, but
i only i want some. What is the best way to clone. I tried underscore, but
nothing happens:
var object = {
name: "Pepe",
age: 25,
widget: {
top: 1,
left: 1,
other: "jeje"
}
};
var a = _.pick(object, "name", "widget.top");
console.log(a);
//Will must return: {name: "pepe", widget: {top: 1}}
No comments:
Post a Comment