87,993
社区成员
发帖
与我相关
我的任务
分享
var arr1 = [1,2,3];
var arr2 = [
$scope.parent[0];
$scope.parent[0].children[1];
$scope.parent[0].children[1].children[2];
$scope.parent[0].children[1].children[2].children[3];
]


var arr1 = [1,2,3];
const INIT='$scope.parent[0]';
arr2=arr1.map(function(item,index){
var init=INIT;
for(var i=1;i<=index+1;i++){
init+=`.children[${i}]`;
}
return init;
});
arr2.unshift(INIT);
console.log(arr2);