Skip to content

Instantly share code, notes, and snippets.

@AkashRajvanshi
Created September 26, 2019 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkashRajvanshi/a0ee8f5dc08df47ed62052d6406365e9 to your computer and use it in GitHub Desktop.
Save AkashRajvanshi/a0ee8f5dc08df47ed62052d6406365e9 to your computer and use it in GitHub Desktop.
function showDetails() {
console.log(`My Name is ${this.fullName}`) // My Name is undefined
}
const User = {
fullName: 'Akash Rajvanshi'
}
//call without any .call()/ .apply()/ .bind()
showDetails()
//As we know in simple function "this" refer to the window object
window.fullname = 'Alash Rajavashi'
function showDetails() {
console.log(`My Name is ${this.fullName}`) // My Name is Akash Rajvanshi
}
showDetails()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment