Possible Duplicate:
“Variable” Variables in Javascript?
I'm thinking surely there is a way to achieve dynamic or variable variables in JavaScript (jQuery) much as one might in php where we might have...
<?php
$params = array("street", "city", "state","zip_code");
foreach($params as $key) $$key = some_function($key);
echo $city; // would output the result of some_function(city);
?>
but I can't see a way to accomplish similar in jQuery (JavaScript) where I would like to have something like...
<script>
params =["street", "city", "state","zip_code"];
jQuery.each(params, function() {
var var this = jQuery('#'+this).val();
});
alert(city);
</script>
Which (of course) doesn't work, but there must be a way?