-
-
Save sente/4057240 to your computer and use it in GitHub Desktop.
Object.keys(), Object.values()
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
| // changed the functions from .keys() -> ._keys(), likewise for .values() | |
| // because .keys()/.values() breaks jQuery | |
| Object.prototype._keys = function (i) { | |
| var keys = Object.keys(this); | |
| return (i >= 0) ? keys[i] : keys; | |
| }; | |
| Object.prototype._values = function (i) { | |
| var self = this; | |
| var values = Object.keys(this).map(function(key){ | |
| return self[key]; | |
| }); | |
| return (i >= 0) ? values[i] : values; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment