Javascript - Function Function bind()

Introduction

The function bind() method creates a new function whose this value is bound to the value that was passed into bind().

For example:

var o = { color: "blue" };
var j = { color: "red" };

function sayColor(){
   console.log(this.color);
}
var objectSayColor = sayColor.bind(o);
var objectSayColor = sayColor.bind(j);

Here, a new function called objectSayColor() is created from sayColor() by calling bind() and passing in the object o.