Skip to content

Instantly share code, notes, and snippets.

@rochapablo
Created August 8, 2018 11:36
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 rochapablo/f4e233c13b2c4bc76046e912a075d1ef to your computer and use it in GitHub Desktop.
Save rochapablo/f4e233c13b2c4bc76046e912a075d1ef to your computer and use it in GitHub Desktop.
Class to Object
console.clear();
var Track = function(attrs) {
this.icon = (attrs && attrs.icon || 'play_arrow');
this.toggle = (attrs && attrs.toggle || 'close');
this.arrow = (attrs && attrs.arrow || 'keyboard_arrow_down');
this.toObject = function() {
var newObject = {};
for (var prop in this) {
if (this.hasOwnProperty(prop) && typeof this[prop] !== 'function') {
newObject[prop] = this[prop];
}
}
return newObject;
}
};
var track = new Track();
console.log(track.toObject());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment