Created
March 22, 2020 06:46
-
-
Save sumitpore/b50f619e6ec04cc441c819238051cc86 to your computer and use it in GitHub Desktop.
Copy/Clone Object excluding specific keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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