How can I pass in a string and use that as a variable name?
I have a variable such as:
var startX = 20
var startY = 30
I want to call a function such as:
onClick="myFunction('startX')"
or
onClick="myFunction('startY')"
myFunction(passedVar){
}
So passedVar = 'startX' or 'startY' and I then need to reference the
variable of the same name and get it's value (20 or 30)
In Powershell I'd do a:
get-variable($passedVar) -value
which would see what's in passedVar and then look for a variable with that
name and give me the value.
Does that make sense?
Thanks!
No comments:
Post a Comment