50. What is the difference between the call, apply and bind methods in JavaScript?
easy
In JavaScript, the call(), apply(), and bind() methods are used to invoke a function with different arguments.
The call() method invokes a function as if it were being called directly on the object (this), passing any additional arguments as properties of that object.
function greet(name) {
  console.log('Hello ' + name + '!');
}
var obj = { name: 'John' };
greet.call(obj, 'Doe');
// Outputs: "Hello John Doe!"
In this example, the call() method is used to invoke the greet() function on the object (this) with the name property and the argument "Doe".

The apply() method invokes a function as if it were being called directly on an array or other iterable object (this), passing any additional arguments as elements of that object.
function greet(name) {
  console.log('Hello ' + name + '!');
}
var names = ['John', 'Doe'];
greet.apply(null, names);
// Outputs: "Hello John Doe!"
In this example, the apply() method is used to invoke the greet() function on an array of strings (names) with no arguments.
The bind() method creates a new function that has a specified value for its "this" property.
function greet(name) {
  console.log('Hello ' + name + '!');
}
var obj = { name: 'John' };
var greeter = greet.bind(obj);
greeter('Doe');
// Outputs: "Hello John Doe!"
In this example, the bind() method is used to create a new function (greeter) that has the value of the object (this) as its "this" property and the argument "Doe".

To summarize, the call() and apply() methods are used to invoke a function with different arguments, while the bind() method creates a new function with a specified value for its "this" property. The choice of which method to use depends on the specific use case and the desired behavior of the resulting function.