DEV Community

Joe Steinbring
Joe Steinbring

Posted on • Originally published at blog.jws.app on

Prototype.call() vs Prototype.apply()

This is going to be a relatively short post. We have been doing a lot of [x] vs [y] vs [z] posts on the main blog and this one is no different. Today, I figured that we would look at Prototype.call() vs Prototype.apply(). Both apply() and call() are used to invoke functions. The difference is that call uses a comma separated list of arguments and apply uses an array of arguments.

Prototype.call() example:

Prototype.apply() example:

For the sake of clarity, both examples do the same thing beyond the one difference. They both have teachers, students, and persons but where one uses Person.apply(this, [fname, lname]); the other one uses Person.call(this, fname, lname);.

Have a question, comment, etc? Feel free to drop a comment, below.

The post Prototype.call() vs Prototype.apply() first appeared on Blog.jws.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)