JavaScript call and apply

A colleague recently came across this line in our codebase that I wrote:
binding.vehicle.involvements.push.apply(binding.vehicle.involvements, vehicle.involvements); What the overall result of the code is isn’t particularly important, the part th…


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail

A colleague recently came across this line in our codebase that I wrote: binding.vehicle.involvements.push.apply(binding.vehicle.involvements, vehicle.involvements); What the overall result of the code is isn’t particularly important, the part that tripped them up (and made them think I’m on drugs I’m not actually on) was this: binding.vehicle.involvements.push.apply(binding.vehicle.involvements, vehicle.involvements); Now the involvements property is an array in both scenarios which exposes a push method, the confusion was around what the apply method does and why I was even using it.


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail


Print Share Comment Cite Upload Translate Updates
APA

Posts on LINQ to Fail | Sciencx (2013-07-04T00:00:00+00:00) JavaScript call and apply. Retrieved from https://www.scien.cx/2013/07/04/javascript-call-and-apply/

MLA
" » JavaScript call and apply." Posts on LINQ to Fail | Sciencx - Thursday July 4, 2013, https://www.scien.cx/2013/07/04/javascript-call-and-apply/
HARVARD
Posts on LINQ to Fail | Sciencx Thursday July 4, 2013 » JavaScript call and apply., viewed ,<https://www.scien.cx/2013/07/04/javascript-call-and-apply/>
VANCOUVER
Posts on LINQ to Fail | Sciencx - » JavaScript call and apply. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2013/07/04/javascript-call-and-apply/
CHICAGO
" » JavaScript call and apply." Posts on LINQ to Fail | Sciencx - Accessed . https://www.scien.cx/2013/07/04/javascript-call-and-apply/
IEEE
" » JavaScript call and apply." Posts on LINQ to Fail | Sciencx [Online]. Available: https://www.scien.cx/2013/07/04/javascript-call-and-apply/. [Accessed: ]
rf:citation
» JavaScript call and apply | Posts on LINQ to Fail | Sciencx | https://www.scien.cx/2013/07/04/javascript-call-and-apply/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.