function at(object, arr) { let ret = []; for (let i = 0; i < arr.length; i++) { let temp = [], ind; temp[0] = object[arr[i][0]]; for (let k = 1; k < arr[i].length; k++) { if (arr[i][k] != '[' && arr[i][k] != ']' && arr[i][k] != '.') { ind++; temp[ind] = temp[ind - 1][arr[i][k]]; } } ret.push(temp[ind]); } return ret; } const object = { 'a': [ { 'b': { 'c': 3, }, }, 4, ], }; // 输出 [3, 4] console.log(at(object, ['a[0].b.c', 'a[1]']));