Skip to content

Instantly share code, notes, and snippets.

@Piterden
Created December 8, 2018 19:25
Show Gist options
  • Select an option

  • Save Piterden/5a5f9af63f8af7567a7da5318e282251 to your computer and use it in GitHub Desktop.

Select an option

Save Piterden/5a5f9af63f8af7567a7da5318e282251 to your computer and use it in GitHub Desktop.
[JS] Camel to dash transform and opposite
'dash-cased-string'.split('-').map((part, idx) => idx ? part.charAt(0).toUpperCase() + part.slice(1) : part).join('')
'camelCasedString'.replace(/([A-Z])/g, '-$1').toLowerCase()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment