Created
November 2, 2015 18:32
-
-
Save kaliaparijat/c169f822efa36a21e174 to your computer and use it in GitHub Desktop.
This file contains 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 omit(obj, keys){ | |
if (typeof obj != 'object') { | |
console.log("this is not an object"); | |
return obj; | |
} | |
var omitThisKey; | |
if (keys instanceof Array) { | |
omitThisKey = function(key) { | |
if(keys.indexOf(key) > -1) { | |
return true; | |
} | |
}; | |
} | |
else if (typeof keys == 'function') { | |
omitThisKey = keys.apply(key); | |
} | |
else if (typeof keys == 'object') { | |
omitThisKey = function(key) { | |
if (key == keys){ | |
return true; | |
} | |
} ; | |
} | |
for(var key in obj) { | |
if(omitThisKey(key)) { | |
delete obj[key] ; | |
} | |
} | |
return obj; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment