Facebook Pixel

What is the most common mistake in a bind polyfill interview?

Not storing this. Inside the returned function, this is not the original function. You must store it before returning: const fn = this. Then use fn.call(context) inside the returned function.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in bind Polyfill Common Mistakes

Because this inside the returned function is different from this inside myBind. Store it: const fn = this. Use fn in the returned function. Without this, the polyfill cannot call the original function.

Because arrow functions do not have their own this. The instanceof check (this instanceof boundFn) would not work with arrows. Use a regular function for the returned function.

The original function would not receive the arguments passed when the bound function is called. For greet.myBind(obj, 'Hello')('!'), the '!' would be lost. Always spread laterArgs: fn.call(context, ...presetArgs, ...laterArgs).

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

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
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.