0% found this document useful (0 votes)
36 views8 pages

Call Bind and Apply in JavaScript 1696917034

Call and apply allow you to control the value of this in a function and execute the function immediately, with call accepting arguments as a comma separated list and apply accepting arguments in an array. Bind returns a new function with this set to the first parameter passed to bind but does not execute the function immediately.

Uploaded by

HIMANSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views8 pages

Call Bind and Apply in JavaScript 1696917034

Call and apply allow you to control the value of this in a function and execute the function immediately, with call accepting arguments as a comma separated list and apply accepting arguments in an array. Bind returns a new function with this set to the first parameter passed to bind but does not execute the function immediately.

Uploaded by

HIMANSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

JavaScript

Call(), Apply() &


Bind()

Let’s Uncover it
Concept

call, bind, and apply are essential


JavaScript methods that allow you to
control the value of this in a function. This
can be incredibly useful in various
scenarios, especially when working with
objects or constructors.

Hafiz M.Ahmed
Software Engineer
Call ( )
The call() method invokes a function with a
given this value and arguments provided
one by one.

Hafiz M.Ahmed
Software Engineer
Apply ( )
Apply: Invokes the function with a given this
value and allows you to pass in arguments
as an array.

Hafiz M.Ahmed
Software Engineer
Bind ( )
bind: returns a new function, allowing you
to pass any number of arguments.

Hafiz M.Ahmed
Software Engineer
Summary

Call and apply are pretty interchangeable.


Both execute the current function
immediately. You need to decide whether
it’s easier to send in an array or a comma
separated list of arguments. You can
remember by treating Call is for comma
(separated list) and Apply is for Array.

Whereas Bind creates a new function that


will have this set to the first parameter
passed to bind().

Hafiz M.Ahmed
Software Engineer
Summary

Call and apply are pretty interchangeable.


Both execute the current function
immediately. You need to decide whether
it’s easier to send in an array or a comma
separated list of arguments. You can
remember by treating Call is for comma
(separated list) and Apply is for Array.

Whereas Bind creates a new function that


will have this set to the first parameter
passed to bind().

Hafiz M.Ahmed
Software Engineer
Hafiz M.Ahmed

Did you find it useful?


Share your thoughts.

You might also like