Created
June 27, 2014 11:39
-
-
Save zykadelic/149de288a3917d0cf310 to your computer and use it in GitHub Desktop.
Returns a new object with only the keys provided as arguments, leaves old object intact
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
if(!Object.prototype.slice){ | |
Object.prototype.slice = function(){ | |
var returnObj = {}; | |
for(var i = 0, j = arguments.length; i < j; i++){ | |
if(this.hasOwnProperty(arguments[i])){ | |
returnObj[arguments[i]] = this[arguments[i]]; | |
} | |
} | |
return returnObj; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment