当前位置:网站首页>链式长取值
链式长取值
2022-07-03 07:49:00 【ange2017】
分享一个链式长取值的function ,代替可选链 。
// 链式长取值
get(source, path, defaultValue = undefined) {
const paths = path.replace(/\[(\d+)\]/g, '.$1').split('.')
let result = source
for (const p of paths) {
result = Object(result)[p]
if (result === undefined) {
return defaultValue
}
}
return result
},边栏推荐
- Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
- Structure of golang
- Usage of requests module
- Pat grade a 1027 colors in Mars
- haproxy+keepalived搭建01
- How does yarn link help developers debug NPM packages?
- 【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
- Go language foundation ----- 02 ----- basic data types and operators
- C language learning notes (mind map)
- Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
猜你喜欢
随机推荐
Client server model
MAE
[at] abc 258G - Triangle 三元組可達-暴力
Go language foundation ----- 08 ----- interface
[at] ABC 258g - triple Reach - violence
PHP常用排序算法
PHP common sorting algorithm
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
HDMI2.1与HDMI2.0的区别以及转换PD信号。
Introduction of novel RNA based cancer therapies
[untitled]
UA camouflage, get and post in requests carry parameters to obtain JSON format content
PAT甲级 1029 Median
register关键字
【LeetCode】2. Valid Parentheses·有效的括号
C2 several methods of merging VCF files
OSPF experiment
RM delete file
Wechat native applet cloud development learning record 01
Go language foundation ----- 10 ----- string related operations (operation function, string conversion)



![[MySQL 12] MySQL 8.0.18 reinitialization](/img/e1/9874df18bbc8d80c3c5c5fe39aefc9.png)




