I started using firebase and I came across the snap =>
when passing value:
var rh = document.getElementById('rh');
var dbref = firebase.database().ref('text')
dbref.on('value', snap => rh.innerText = snap.val())
I would like to understand what it does and what is the use of it.
It's just simple syntax for a function. Instead of:
function f(snap) {
return "hello world";
}
const c = f;
You can write the following to make it easier to read:
const c = snap => return "hello world";
Now c
is a constant that holds the function above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.