How can I get a constant's value dynamically similar to constant()
in PHP?
Below, I would like to access HELL_NO
, but I have NO
in a variable. Why does this return undefined
?
const HELL_YES='warm';
const HELL_NO='cool';
var pick='NO';
console.log(window['HELL_'+pick]);