[Solved] How to overwrite values using jquery or javascript? [closed]


It’s relatively straightforward using the hasOwnProperty function:

for(var key in _newProperties) {
    if(rectangle.hasOwnProperty(key)) {
        rectangle[key] = _newProperties[key];
    }
}

This loops through the keys in _newProperties and writes the values to rectangle iff rectangle has a property with the same name. Note that properties inherited through prototypes will be ignored because hasOwnProperty will return false for them.

solved How to overwrite values using jquery or javascript? [closed]