-
-
Save rochapablo/f4e233c13b2c4bc76046e912a075d1ef to your computer and use it in GitHub Desktop.
Class to Object
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
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