Created
September 26, 2019 07:20
-
-
Save AkashRajvanshi/89ba426565b363e7996e5bafda065475 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showDetails() { | |
console.log(this) // { firstName: 'Akash', lastName: 'Rajvanshi' } X 3 | |
console.log(this.firstName, this.lastName) // Akash Rajvanshi x 3 | |
} | |
var fullName = { | |
firstName: 'Akash', | |
lastName: 'Rajvanshi' | |
} | |
var exampleOfHardBinding = function () { | |
showDetails.call(fullName) | |
} // Hard bounded | |
exampleOfHardBinding() // 1st Call | |
setTimeout(exampleOfHardBinding, 100) // 2nd call | |
// hard bound 'exampleOfHardBinding' can no longer have its 'this' overridden | |
exampleOfHardBinding.call(window) // 3rd Call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment