Function.prototype.bind in JavaScript

The bind() method preserves the context of 'this' and current parameters for future execution. Typically, it is used to preserve execution context for a function that executes in another context. The bind() creates a new function that has the same body as the original function. The first argument passed to bind specifies the value of the this keyword in the bound function. You can also pass additional, optional arguments to bind. example
<script> globalVal = 555; var module = { globalVal: 999, GetValue: function () { return this.globalVal; } }; alert(module.GetValue()); // 999 var GetValue = module.GetValue; alert(GetValue()); // 555 refers to the global object // create a new function with 'this' bound to module var boundGetX = GetValue.bind(module); alert(boundGetX()); // 999 </script>