JSFiddle - React, Tailwind, and code Playground

by userdude

JavaScript

function replacer(obj, keys)
{
    var dup = {};
    for (key in obj) {
        if (keys.indexOf(key) == -1) {
            dup[key] = obj[key];
        }
    }
    return dup;
}

var x = {
    'x':0,
    'y':0,
    'divID':"xyz", 
    'privateProperty1': 'foo',
    'privateProperty2': 'bar'
};

alert(JSON.stringify(replacer(x, ['privateProperty1','privateProperty2'])));