Is there a way to use a variable as a JSON key in JavaScript?
var chtid = "1234"
firebase.database().ref().set ({chtid :"hi"});
In this case, chtid
is the variable.
I have attempted this method without success:
var chtid = "1234"
firebase.database().ref().set ({[chtid] :"hi"});
If anyone has a simple solution, please share.