-
Affected URL(s)https://nodejs.org/api/events.html#class-eventemitter Description of the problemHi guys, why does "this" in the listener function log as the class MyEmitter, rather than the instance myEmitter, of the class? This is the text on the doc
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
console.log()
shows the class name where available to let you know the type of object you're logging. In this case,myEmitter
is an instance ofMyEmitter
, so it shows that class name. The properties shown in the output are those that belong to that specific instance (this
) and not the class/constructor.