Answers for "delete multiple keys from object javascript"

0

delete multiple keys from object javascript

var obj = {a: 1, b: 2, c: 3, d: 4, e: 5 };

['c', 'e'].forEach(e => delete obj[e]);

// obj is now {a:1, b:2, d:4}
Posted by: Guest on September-09-2020
0

delete multiple keys from object javascript

const obj = {
        a: 'dog',
        b: 'cat',
        c: 'mouse',
        d: 'cow',
        e: 'horse',
    };
const {a, e, ...updatedObject} = obj;

// output
console.log(updatedObject)
Posted by: Guest on September-09-2020

Code answers related to "delete multiple keys from object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language