border-left-width를 borderLeftWidthë¡ ë³ê²½í기
ì¤ìë: 5
"my-short-string"ê°ì´ ì¬ë¬ ë¨ì´ë¥¼ ëì(-)ë¡ êµ¬ë¶í 문ìì´ì ì¹´ë© í기ë²ì ì¬ì©í 문ìì´ "myShortString"ë¡ ë³ê²½í´ì£¼ë í¨ì를 ìì±í´ë³´ì¸ì.
ëìë 모ë ì§ì°ê³ ê° ë¨ì´ì 첫 ë²ì§¸ ê¸ìë ë문ìë¡ ì¨ì£¼ë©´ ë©ëë¤.
ìì:
camelize("background-color") == 'backgroundColor';
camelize("list-style-image") == 'listStyleImage';
camelize("-webkit-transition") == 'WebkitTransition';
íí¸: splitì ì¬ì©í´ 문ìì´ì ë°°ì´ë¡ ë°ê¾¼ ë¤ì joinì ì¬ì©í´ ë¤ì í©ì¹ë©´ ë©ëë¤.
í ì¤í¸ ì½ëê° ë´ê¸´ ìëë°ì¤ë¥¼ ì´ì´ ì ëµì ìì±í´ë³´ì¸ì.
function camelize(str) {
return str
.split('-') // splits 'my-long-word' into array ['my', 'long', 'word']
.map(
// capitalizes first letters of all array items except the first one
// converts ['my', 'long', 'word'] into ['my', 'Long', 'Word']
(word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1)
)
.join(''); // joins ['my', 'Long', 'Word'] into 'myLongWord'
}
í ì¤í¸ ì½ëê° ë´ê¸´ ìëë°ì¤ë¥¼ ì´ì´ ì ëµì íì¸í´ë³´ì¸ì.