Facebook Pixel
Common Mistakes with call, apply, and bind

What is the first argument to call, apply, and bind?

The answer

The this value. fn.call(thisArg, arg1, arg2). fn.apply(thisArg, [arg1, arg2]). fn.bind(thisArg, arg1, arg2). If you do not care about this, pass null.

More FAQs in Common Mistakes with call, apply, and bind

call takes comma-separated arguments: fn.call(obj, arg1, arg2). apply takes an array: fn.apply(obj, [arg1, arg2]). Both invoke immediately with the specified this.

No. bind returns a new function with this bound. You must call it separately. This is the key difference from call and apply, which invoke immediately.

No. The first bind wins. bound.bind(newObj) does not change this. The bound function keeps the original this from the first bind call.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Your learning library

Small steps. Big possibilities.

Find your next course. Build something great.

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.