I have a few variables which are defined as:
function test() {
var foo = 'bar'
var dict = {
foo: 'haha'
}
Logger.log(dict['foo']) // haha
Logger.log(dict[foo]) // undefined. I expected this to return 'haha'. But I was wrong.
}
Is it possible to create a dictionary that contains bar
as its key using the variable foo
?
I mean I want to get 'haha'
by using the variable foo
.