【发布时间】:2016-06-08 21:20:14
【问题描述】:
我不太明白下面两行代码的区别。在我的代码中,带有“应用”的行按我想要的方式工作,而只有常规推送的行却没有。
那么当这两个都被执行时到底发生了什么:
//this one does not work the way i want it to
$scope.items.push(result.data.stuff)
//this one works!
Array.prototype.push.apply($scope.items, result.data.stuff);
编辑:很抱歉造成混淆,我已对其进行了修复,使其具有“推送”方法
【问题讨论】:
-
有没有“定期推送”的行?是的,我很确定
$cope.items.push(result.data.stuff[0], results.data.stuff[1], …)会起作用。 -
抱歉造成混淆...我已修复。请再看推线。
标签: javascript javascript-objects apply