function at(object, arr) { // var value = ""; for(let i = 0; i < arr.length; i++) { var key = arr[i]; value += eval("object."+key); if(!i)value += ","; } return value; } const object = { 'a': [ { 'b': { 'c': 3, }, }, 4, ], }; // 输出 [3, 4] console.log(at(object, ['a[0].b.c', 'a[1]']));