当前位置:网站首页>JS changes the words separated by dashes into camel style
JS changes the words separated by dashes into camel style
2022-04-23 03:26:00 【Open the door of the world】
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'
}
console.log(camelize('background-color')); // backgroundColor
console.log(camelize('list-style-image')); // listStyleImage
console.log(camelize('-webkit-transition')); // WebkitTransition
版权声明
本文为[Open the door of the world]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619451056.html
边栏推荐
- Using swagger in. Net5
- 12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
- 关于idea调试模式下启动特别慢的优化
- MySql关键字GROUP_CONCAT,组合连接查询
- 2022 团体程序设计天梯赛 模拟赛 L1-7 矩阵列平移 (20 分)
- Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions
- Database - MySQL -- Navicat import SQL error 1067 - invalid default value for 'paydate‘
- Explication détaillée des fonctions send () et recv () du programme Socket
- Talent Plan 学习营初体验:交流+坚持 开源协作课程学习的不二路径
- Un aperçu des flux d'E / s et des opérations de fichiers de classe de fichiers
猜你喜欢
Course design of Database Principle -- material distribution management system
Visual programming - Experiment 2
关于idea调试模式下启动特别慢的优化
可以接收多种数据类型参数——可变参数
Unity Basics
Optimization of especially slow startup in idea debugging mode
. net 5 Web custom middleware implementation returns the default picture
2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
12.<tag-链表和常考点综合>-lt.234-回文链表
Web Course Design - his system
随机推荐
2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
Eight elder brothers chronicle [4]
Flink customizes the application of sink side sinkfunction
C set
集合之List接口
Flink real-time data warehouse project - Design and implementation of DWS layer
关于idea调试模式下启动特别慢的优化
Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
Do you really understand hashcode and equals???
QT dynamic translation of Chinese and English languages
Comprehensive calculation of employee information
Quartz. Www. 18fu Used in net core
Oracle query foreign keys contain comma separated data
二进制文件版本控制工具选择难?看完这篇你会找到答案
The query type of MySQL is very inefficient.
. NETCORE sets the API post mode, which can accept parameters directly in parentheses
Flink实时数仓项目—DWS层设计与实现
12.<tag-链表和常考点综合>-lt.234-回文链表
MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)