Skip to content

Instantly share code, notes, and snippets.

@vdeturckheim
Created March 24, 2016 14:08
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 vdeturckheim/275832f0ffebec886295 to your computer and use it in GitHub Desktop.
Save vdeturckheim/275832f0ffebec886295 to your computer and use it in GitHub Desktop.
/**
* Transforms an object to an array (drop the Object's keys)
* ```
* let x = { a: 1, b: 2};
* x.mapToArray() is [1, 2];
* ```
* @returns {Array}
*/
Object.prototype.mapToArray = function () {
var self = this;
return Object.keys(self).map(function (key) {
return self[key];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment