voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
22 lines (12 loc) • 853 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/database](./database.md) > [DataSnapshot](./database.datasnapshot.md) > [hasChildren](./database.datasnapshot.haschildren.md)
## 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`<!-- -->).
<b>Signature:</b>
```typescript
hasChildren(): boolean;
```
<b>Returns:</b>
boolean
true if this snapshot has any children; else false.