How can i copy all the attributes of a JSON object except one or two attributes?
1 min readOct 10, 2018
- Using the Rest operator
Example:
var t={a:9,b:90,c:”pojd”};
var {a,c,…re}=t;//re={b:90},a=9,c=”pojd” - Using Enumerable properties
Make the attribute as nonenumerable while declaring.
var test = {a:4};
Object.defineProperty(test, “nonEnum”, { enumerable: false });
test.nonEnum=9;
test.b=0;
var y=JSON.stringify(test);
var yup=JSON.parse(y);// yup={a:4,b:0}