Skip to content

Instantly share code, notes, and snippets.

@sumitpore
Created March 22, 2020 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumitpore/b50f619e6ec04cc441c819238051cc86 to your computer and use it in GitHub Desktop.
Save sumitpore/b50f619e6ec04cc441c819238051cc86 to your computer and use it in GitHub Desktop.
Copy/Clone Object excluding specific keys
function _objectWithoutProperties(obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
}
// Usage
var y = _objectWithoutProperties(x, ["b"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment