Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #297244
    Pranab
    Participant

    I have some confusion on this.

    class Func {
      greet() {
        console.log(this);
      }
    }
    let g = new Func();
    console.log(g.greet()===g);
    

    I thought this value is pointing to the newly created object itself but it returns false.
    Can anyone explain what’s really happen?

    #297245
    Pranab
    Participant

    Sorry. My mistake. I should have return this instead of logging it.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.