JavaScript Function.prototype.bind() Method Last Updated : 08 Dec, 2021 Comments Improve Suggest changes Like Article Like Report A function is a set of statements that take inputs, do some specific computation, and produce output. There are various scenarios in programming in which we need to pre-configure this keyword or function arguments and we can easily do that in JavaScript with the help of the bind() method. The bind() method creates a new function based on the function on which it is called. Using the bind() method, we can pre-configure this keyword and arguments for the function using the syntax shown below. Syntax: const newFunction = oldFunction.bind(thisArg, arg1, ag2, ..., argN) Using the above syntax, a new function is created based on the old function with this keyword set to thisArg, and function arguments are preconfigured as arg1, agr2, and so on. The example mentioned below demonstrates the use of the bind() method with the help of an example. Example: JavaScript <script> const car = { brand: 'Lamborghini', }; // As of now, 'this' keyword refers // to 'window' object. const printDetail = function (model, topSpeed) { console.log(`${this.brand} ${model} has a top speed of ${topSpeed} mph`); }; // Calling the function without using bind which // means 'this' still refers to 'window' object // so accessing this.brand will give undefined printDetail('Diablo Coatl', 239); // Creating a new function based on printDetail // with 'this' keyword referring to car object // so accessing this.brand will give 'Lamborgini' const lamboPrintDetail = printDetail.bind(car); lamboPrintDetail('Diablo VTTT', 222); // Creating another function based on printDetail // with it's arguments pre-configured and 'this' // keyword referring to car object const reventonPrintDetail = printDetail.bind(car, 'Reventon', 221); // Since the arguments are preconfigured so we don't // need to pass any argument to call this function reventonPrintDetail(); </script> Output: undefined Diablo Coatl has a top speed of 239 mph Lamborghini Diablo VTTT has a top speed of 222 mph Lamborghini Reventon has a top speed of 221 mph Comment More infoAdvertise with us Next Article JavaScript Function.prototype.bind() Method S shivamsingh00141 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Methods Similar Reads JavaScript Function.prototype.call() Method The call() method allows function calls belonging to one object to be assigned and it is called for a different object. It provides a new value of this to the function. The call() method allows you to write a method once and allows it for inheritance in another object, without rewriting the method f 3 min read JavaScript Function name Property The function name property of the javascript object is used to return the name of the function. This name property of the function is only readable and cannot be altered. The name of the function which was given when the function was created is returned by Function.name. Syntax: Function.name Proper 3 min read Prototype Method - JavaScript Design Pattern A Prototype Method is a JavaScript design pattern where objects share a common prototype object, which contains shared methods. The prototype method allows you to reuse the properties and methods of the prototype object, and also add new ones as needed. The prototype method is useful for performance 3 min read JavaScript Handler setPrototypeOf() Method JavaScript handler.setPrototypeOf() method in JavaScript is a trap for Object.setPrototypeOf() method and it returns a Boolean value. Syntax: const p = new Proxy(target, { setPrototypeOf: function(target, prototype) { } }); Parameters: This method accepts two parameters as mentioned above and descri 2 min read What is the usage of Function.prototype.bind in JavaScript ? Bind method: Using this method, we can bind an object to a common function, so that gives different result when its needed. The bind() method takes an object as an argument and creates a new function. So basically bind function return function. Let's understand when bind method is used. bind the obj 2 min read Like