Typically if you're converting a string of words to camel case you capitalise only the first letter of every word (bar the first word).
How does this apply to hyphenated words like re-render?
Something deep inside me wants it to be rerender
or doRerender
. And not reRender
or doReRender
, which just looks wrong to me.
Is this open to interpretation or is camel casing clear on this, and I'm just not seeing it?
Compound words can be written in three ways: as open compounds (spelled as two words, e.g., ice cream), closed compounds (joined to form a single word, e.g., doorknob), or hyphenated compounds (two words joined by a hyphen, e.g., long-term). Sometimes, more than two words can form a compound (e.g., mother-in-law).
CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.
In camel-case, individual trailing words are capitalized and whitespace is dropped. Since "re-render" is a single word, and since the hyphen is a non-alpha character in the same vein as whitespace, it should be treated as a single word would normally.
let rerender = "The correct answer";
The same would be true for these other examples containing hyphenated prefixes (as opposed to hyphenated standalone words):
sub-zero wedding cake : subzeroWeddingCake
co-parent advisory hose : coparentAdvisoryHose
ongoing trans-oceanic puppies : ongoingTransoceanicPuppies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With