'How to observe Firebase child values in JavaScript

How can I observe a child's value in JavaScript. In Swift you simply put:

        ref.child("user").observe(.value) { (snapshot) in 
            let userId = snapshot.key 
         }

What is the command for this in JavaScript?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source