Using a variable as a hash key in Coffeescript -


let's have hash in coffeescript:

exercises =   stretchedprayer:     name: "stretched prayer"     sound: "28-stretched-prayer"   bandstretch:     name: "band stretch"     sound: "13-band-stretch" 

i can correctly name of first exercise following code:

exercises.stretchedprayer.name 

what want call same name know exercise want variable extracted id on web page.

in other words, if have variable such

myexercise = "stretchedprayer" 

how can name of practice in hash using variable?

just use square brackets, in javascript.

exercises[myexercise].name 

object[property] same object.<<property's value>>


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -