DEV Community

Discussion on: Typical JavaScript interview exercises (explained)

Collapse
 
gdotdesign profile image
Szikszai Gusztáv • Edited

I've been writing for about a decade now, but didn't know about that it is possible to bind functions to objects like this:

let dog = {
   sayName () {
    console.log(this.name)
  }
}

Is this a relatively new thing or it has always worked like this? Are there any reference material on this?