How can i copy all the attributes of a JSON object except one or two attributes?

Arun Rajeevan
1 min readOct 10, 2018

--

  1. 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”
  2. 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}

--

--

No responses yet