What is the usage of Function.prototype.bind in JavaScript ? Last Updated : 26 Mar, 2022 Comments Improve Suggest changes Like Article Like Report 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 object with common function Example 1: JavaScript <script> const gfg = { name: "javascript", content: "prototype", feature: function () { console.log( `Help in learning ${this.name}. The topic is ${this.content}` ); } } // Simple method to feature of gfg object gfg.feature(); console.log() // Try to bind gfg object property feature // to other common function so that it // used for later use but it does not // happen here let b = gfg.feature; b(); console.log() // Now try to bind object using bind // method // bind method first argument refer // object that's why parameter gfg object let c = gfg.feature.bind(gfg); c(); </script> Note: Bind different objects to a common function so that each object can access that function and extra functionality to objects so bind function takes any number of arguments. Example 2: JavaScript <script> const gfg = { name: "javascript", content: "prototype", } const gfg1 = { name: "c++", content: "inheritance", } const gfg2 = { name: "java", content: "applet", } // Function which is binding with different object function features(param) { console.log(`Help in learning ${this.name}. The topic is ${this.content} and these are help in ${param}`) } // Binding obj1 abd extra functionality let bindfunc = features.bind(gfg); bindfunc("placement"); // Binding obj2 let bindfunc1 = features.bind(gfg2); bindfunc1("placement"); </script> Comment More infoAdvertise with us Next Article What is the usage of Function.prototype.bind in JavaScript ? S surbhikumaridav Follow Improve Article Tags : JavaScript Web Technologies Geeks Premier League Geeks-Premier-League-2022 JavaScript-Questions Similar Reads JavaScript Function.prototype.bind() Method 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() 2 min read JavaScript - What is the Purpose of Self Executing Function? The self-executing anonymous function is a special function which is invoked right after it is defined. There is no need to call this function anywhere in the script. This type of function has no name and hence it is called an anonymous function. The function has a trailing set of parentheses. The p 2 min read What is the (function() { } )() construct in JavaScript? If you've ever played around with JavaScript, you might have seen this expression. It's like a strange set of symbols, but it has a special name that is an immediately invoked function expression, or IIFE. In this article, we will understand each element of the expression as well as the functionalit 3 min read Understanding the Prototype Chain in JavaScript The prototype chain is a core JavaScript concept enabling the inheritance of properties and methods between objects. It facilitates code reuse, efficient property lookup, and object hierarchy creation.Every JavaScript object has an internal link to another object, called its prototype.The prototype 3 min read What is the syntax for leading bang! in JavaScript function ? Before we get to know the syntax for the leading bang! in a JavaScript function, let's see what functions in JavaScript are actually are. JavaScript functions are a set of statements(procedures) that perform some tasks or calculate some value. A function may take some input and return the result to 2 min read Like