[Javascript] dynamic var names
Scott Reynen
scott at randomchaos.com
Tue Aug 7 17:22:37 CDT 2007
On Aug 7, 2007, at 3:18 PM, Troy III Ajnej wrote:
> My understanding is that you are trying to asign a value to the value!
Not exactly. A dynamic variable name would assign a value to a
variable with the name of a value. It's a pretty obscure concept,
but in PHP, for example, you can do this like so:
$variableName = 'foo';
${ $variableName } = 'bar';
print( $foo ); // outputs 'bar'
I've only ever found that useful in two contexts, neither of which
appear to apply here: 1) obfuscation (i.e. making code more confusing
than necessary) and 2) meta-programming (i.e. writing another
programming language within PHP).
Peace,
Scott
More information about the Javascript
mailing list