DEV Community

Discussion on: Understanding "this" in JavaScript

Collapse
 
donnisnoni profile image
Don Alfons Nisnoni • Edited

BTW, it would work


let person = {
  firstName: 'George'
}

person.printName = function(greeting) {
  console.log(greeting + " " + this.firstName)
}


printName('Hello') // Hello George