I have the following script which checks if my object has object properties starting with addr. how can I remove those properties from the object? as well as create a new object containing just those properties removed.
const dataObj = {
firstName: "David Dynamic",
id: "13249906",
lastName: "Garcia",
address1: "Test Address1",
address2: "Test Address2"
}
if (Object.keys(dataObj).some(function(k) {
return ~k.indexOf("addr")
})) {
console.log('Has address fields');
} else {
console.log('Does not have address fields');
}