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


The last token in a Firebase database location is considered its key. For example, "fred" is the key for Calling key() on any Firebase reference (except the root) will return its key name:

var fredRef = new Firebase("");
var key = fredRef.key();  // key === "fred"
key = fredRef.child("name/last").key();  // key === "last"

Calling key() on the root of a Firebase reference will return null:

var rootRef = new Firebase("");
var key = rootRef.key();  // key === null