翻译
文章与新闻
推荐库
- Chromogen:生成Recoil测试文件
- remember: 一个web端笔记应用,同时支持chrome扩展使用
- fastest-levenshtein:测量字符串之间的差异
- vscode-debug-visualizer:vscode可视化调试插件
每周一练
实现类似解构赋值的算法,具体例子如下所示:
输入:[1, [2, 3, [4]], 5] '[a, [b, [c], e], d, f]'
输出:{ a: 1, b: 2, c: 4, e: undefined, d: 5, f: undefined }
注意:e和f没有匹配到任何值
/**
* @param {Array} a
* @param {String} b
*/
function dismantleArray(a, b) {}
期望结果:
const res = dismantleArray([1, [2, 3, [4]], 5], '[a, [b, [c], e], d, f]')
console.log(res) // { a: 1, b: 2, c: 4, e: undefined, d: 5, f:undefined }