Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #11728
| From | Tuxedo <tuxedo@mailinator.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Creating a variable named by function parameter? |
| Date | 2012-02-12 17:20 +0100 |
| Organization | albasani.net |
| Message-ID | <jh8ost$tsh$1@news.albasani.net> (permalink) |
A likely trivial question: ...
How can a variable best be named from a parameter passed via function? For
example: ..
function makeup(x){
var ??? = document.title;
}
makeup('stripes');
.. so if makeup('stripes') is run, the variable within the function would
be named 'stripes'.
More precisely, what I would like to do is to append a string to a partly
pre-named variable, while the string passed via the parameter would become
the second part of the variable name, such as:
function makeup(x){
var zebra??? = document.title;
}
makeup('stripes');
.. so the variable name would then become 'zebrastripes'. What is a good
method of doing this?
Many thanks,
Tuxedo
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Creating a variable named by function parameter? Tuxedo <tuxedo@mailinator.com> - 2012-02-12 17:20 +0100
Re: Creating a variable named by function parameter? Martin Honnen <mahotrash@yahoo.de> - 2012-02-12 17:44 +0100
Re: Creating a variable named by function parameter? Tuxedo <tuxedo@mailinator.com> - 2012-02-12 19:26 +0100
Re: Creating a variable named by function parameter? Tuxedo <tuxedo@mailinator.com> - 2012-02-12 21:47 +0100
Re: Creating a variable named by function parameter? RobG <rgqld@iinet.net.au> - 2012-02-12 18:42 -0800
Re: Creating a variable named by function parameter? Tuxedo <tuxedo@mailinator.com> - 2012-02-13 18:28 +0100
Re: Creating a variable named by function parameter? Robert K Quinlivan <rquinlivan@gmail.com> - 2012-02-13 21:02 -0800
Re: Creating a variable named by function parameter? Tuxedo <tuxedo@mailinator.com> - 2012-02-14 22:55 +0100
csiph-web