What is the difference between addListener(event, listener) and on(event, listener) method in node.js?

.on() is exactly the same as .addListener() in the EventEmitter object.

Straight from the EventEmitter source code:

EventEmitter.prototype.on = EventEmitter.prototype.addListener;

Sleuthing through the GitHub repository, there is this checkin from Jul 3, 2010 that contains the comment: “Experimental: ‘on’ as alias to ‘addListener'”.


Update in 2017: The documentation for EventEmitter.prototype.addListener() now says this:

Alias for emitter.on(eventName, listener).

Leave a Comment