Javascript 如何显示预期的数组结果
嗨,这是我生成的数组Javascript 如何显示预期的数组结果,javascript,arrays,Javascript,Arrays,嗨,这是我生成的数组 var iddate = value; $scope.current_children[$scope.current_children_index].shift.push(arr); resut: shift { 1: { 3045_20201123 : "AM" } 2: { 3042_20201123 : "PM" } 3: { 3041_20201123 : &q
var iddate = value;
$scope.current_children[$scope.current_children_index].shift.push(arr);
resut:
shift { 1: { 3045_20201123 : "AM" }
2: { 3042_20201123 : "PM" }
3: { 3041_20201123 : "AM" }
}
我希望产生价值
shift
{ 3045_20201123 : "AM "
3042_20201123 : "PM"
3041_20201123 : "AM"
}
如何生成我期望的结果
shift
是一个数组,您正在将元素推送到该数组中。相反,将shift
设为一个对象,只需将值赋给它即可
var iddate = value;
$scope.current_children[$scope.current_children_index].shift = arr;
假设arr
是您要保留的对象。如果没有,请澄清你的问题