我不太明白以下两行代码之间的区别.在我的代码中,带有"apply"的行按照我想要的方式工作,而只有常规push的行不会.
那么当这两个都被执行时真正发生了什么
//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);
Run Code Online (Sandbox Code Playgroud)
编辑:抱歉混淆,我修复它,以便它有"推"方法