The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/database > DataSnapshot > hasChildren

DataSnapshot.hasChildren() method

Returns whether or not the DataSnapshot has any non-null child properties.

You can use hasChildren() to determine if a DataSnapshot has any children. If it does, you can enumerate them using forEach(). If it doesn't, then either this snapshot contains a primitive value (which can be retrieved with val()) or it is empty (in which case, val() will return null).

Signature:

hasChildren(): boolean;

Returns:

boolean

true if this snapshot has any children; else false.