Convert the string to lower-case, and join words with
A word is any substring that starts with an upper-case character (e.g. in “camelCase”), or is separated by non-alphanumeric characters (spaces, punctuation, etc).
A “slug” is a token that is commonly added to a URL to make it more human readable and optimized for search engines. (The term comes from the publishing industry.)
'list of posts'.slug() //= 'list-of-posts' 'listOfPosts'.slug() //= 'list-of-posts' 'list of posts'.slug('_') //= 'list_of_posts'