Last active
February 13, 2017 22:17
-
-
Save appellation/578d2f77e1599b324b2a088403707230 to your computer and use it in GitHub Desktop.
snek_case to camelCase
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
class Camel { | |
constructor(data) { | |
for(const prop in data) | |
if(data.hasOwnProperty(prop)) | |
this[prop.replace(/_([a-z])/, (match, p1) => p1.toUpperCase())] = data[prop]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment