From a24db4310195f790e15e112c4e45a5c06aedb6f0 Mon Sep 17 00:00:00 2001 From: "Samuel Mills (Henchman)" Date: Tue, 2 Jun 2015 02:05:00 +0200 Subject: [PATCH] docs: event emitter behavior notice Updated documentation as per the issue below: https://github.com/joyent/node/issues/25466 Event listeners can alter parts of the passed object, in some circumstances the changes are passed to the next listeners due to pass by reference. This is documentation of that behavior. PR-URL: https://github.com/joyent/node/pull/25467 Reviewed-By: jasnell - James M Snell --- doc/api/events.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/events.markdown b/doc/api/events.markdown index 857d5658bbd517..cbd3d8814b9e9e 100644 --- a/doc/api/events.markdown +++ b/doc/api/events.markdown @@ -118,6 +118,10 @@ Execute each of the listeners in order with the supplied arguments. Returns `true` if event had listeners, `false` otherwise. +**Note:** Objects are passed by reference, meaning that the same object can be +passed to multiple listeners. If a listener needs to modify a shared object, a +copy of the object should be made. + ### Class Method: EventEmitter.listenerCount(emitter, event)