Using call to invoke an anonymous function

/ Published in: JavaScript
Save to your folder(s)

In this purely constructed example, we create anonymous function and use call to invoke it on every object in an array. The main purpose of the anonymous function here is to add a print function to every object, which is able to print the right index of the object in the array. Passing the object as this value was not strictly necessary, but is done for explanatory purpose.


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.