[Javascript] dynamic var names

John Warner john at jwarner.com
Tue Aug 7 17:26:29 CDT 2007


Looks like an indirect pointer from C/C++

John Warner


> -----Original Message-----
> From: javascript-bounces at LaTech.edu 
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Scott Reynen
> Sent: Tuesday, August 07, 2007 6:23 PM
> To: [JavaScript List]
> Subject: Re: [Javascript] dynamic var names
> 
> 
> 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