You're viewing the legacy docs. They are deprecated as of May 18, 2016.
These docs are for version 2.4.2 and below of the Javascript SDK. Go to our current docs, or see our Web migration guide.

Version 2.4.2Changelog

Firebase.off()

Detach a callback previously attached with on(). Note that if on() was called multiple times with the same eventType and callback, the callback will be called multiple times for each event, and off() must be called multiple times to remove the callback. Calling off() on a parent listener will not automatically remove listeners registered on child nodes, off() must also be called on any child listeners to remove the callback.

If a callback is not specified, all callbacks for the specified eventType will be removed. Similarly, if no eventType or callback is specified, all callbacks for the reference will be removed.

var onValueChange = function(dataSnapshot) { /* handle... */ };
firebaseRef.on('value', onValueChange);
firebaseRef.child('meta-data').on('child_added', onChildAdded);
// Sometime later...
firebaseRef.off('value', onValueChange);

// You must also call off() for any child listeners on firebaseRef
// to cancel those callbacks
firebaseRef.child('meta-data').off('child_added', onValueAdded);
// Or you can save a line of code by using an inline function
// and on()'s return value.
var onValueChange = firebaseRef.on('value', function(dataSnapshot) { /* handle... */ });
// Sometime later...
firebaseRef.off('value', onValueChange);