解析函数
function parse(obj = {a: [1, {b: 2}]}, path = 'a[1].b'){ path = path.replace(/\[/g,'.') path = path.replace(/\]/g,'') let splitPath = path.split('.') let val = obj for(let i = 0;i < splitPath.length;i++){ let item = splitPath[i] val = val && val[item] } return val }
以自己现在的努力程度,还没有资格和别人拼天赋