JavaScript Function bind()

The JavaScript Function bind() method creates a new function.

Syntax:

function.bind (thisArg [arguments])

Parameters: thisArg: It is used as this keyword for the call to a function. arguments: It represents the function parameters.

Return: A new function will be the replica of the calling function.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var jewel =
{
stone: "DIAMOND",
getjewel: function()
{
return this.stone;
}
}
var getjewel1 = jewel.getjewel;
var getjewel2 = getjewel1.bind(jewel);
document.writeln(getjewel2());
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com