🔗 Function.prototype.bind() Polyfill
Category: js / polyfills
Difficulty: hard
Interview Importance: 🔴 Critical — One of the holy trinity of call, apply, bind questions. Understanding bind demonstrates deep knowledge of JavaScript's this binding and closures. 1️⃣ What is bind()? Function.prototype.bind() creates a new function that, when called, has its this keyword set to a specified value, with a given sequence of arguments preceding any provided when the new function is called. [code example] Key Characteristics Description New function with bound this Modifies original? Yes (can preset arguments) Works as constructor? 2️⃣ Why Use bind()? Common Use Cases Problem this refers to DOM element this lost in callback this becomes window Need preset arguments Lose context when extracting Real-World Example [code example] 3️⃣ Native API Signature [code example] Description Value to use as this inside bound function arg1, arg2, ......