当前位置:网站首页>驼峰命名对像
驼峰命名对像
2022-04-23 06:25:00 【笔描相思】
function mapKeyToCamelCase(data) {
// 参考答案
const rename = (name) => {
return name.split('_').reduce((pre, current) => {
return pre + current[0].toUpperCase() + current.substring(1)
});
}
let res = Array.isArray(data) ? [] : {};
for (let i in data) {
if (typeof data[i] === 'object' && data[i] !== null) {
res[rename(i)] = mapKeyToCamelCase(data[i])
} else {
res[rename(i)] = data[i];
}
}
return res;
}
版权声明
本文为[笔描相思]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_44788119/article/details/120920501
边栏推荐
猜你喜欢
js之预解析
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
Background management system framework, there is always what you want
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
简单易懂的子集dp
SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
On BFC (block formatting context)
FSM有限状态机
H5 case development
MySQL index
随机推荐
H5 case development
【TED系列】一个习惯是如何改变我的一生
npm 安装踩坑
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
1D/1D动态规划学习总结
简单易懂的子集dp
9.常用函数
[self motivation series] what really hinders you?
Two threads print odd and even numbers interactively
MVCC(多版本并发控制)
js之节点操作,为什么要学习节点操作
8. Paging query
Mobile game performance optimization
Discussion on arrow function of ES6
Redis connection error err auth < password > called without any password configured for the default user
MySQL isolation level
【自我激励系列】你永远不会准备好
刨根问底---cocos2d源码的理解与分析
Processing of common dependency module
FSM有限状态机