How To Remove All Getters And Setters From An Object In Javascript And Keep Pure Value
I'm using a library called which takes a JS object as an input. Unfortunately, the JSONP api that I am using returns an object containing getters and setters, which this particular
Solution 1:
a solution for this special case/environment/setting might look like that ...
var
obj = JSON.parse(JSON.stringify(model));
console.log("obj before : ", obj);
Object.keys(obj).reduce(function (obj, key) {
if (obj["_" + key] === obj[key]) {
delete obj["_" + key];
}
return obj;
}, obj);
console.log("obj after : ", obj);
see also ... http://jsfiddle.net/w23uLttu/8/
Post a Comment for "How To Remove All Getters And Setters From An Object In Javascript And Keep Pure Value"