I have just realized that I am unable to explain to myself why I can not do in JavaScript what I can do very easily in php. The issue is very simple and basic. Please compare the two following very short scripts and let me know what I miss to get.
<?php
$varA='aaa';
$AA='A';
echo 'var'.$AA; // outputs varA
echo ${'var'.$AA}; // outputs aaa
?>
Instead
<script type="text/javascript" >
var varA = 'aaa';
var AA = 'A';
alert('var'+AA); // outputs varA
alert(---???---); // I wish to output aaa, I am unbale to get it!
</script>
eval. If you need this sort of logic, you're probably doing it wrong.window['var'+AA]will work. But only becausevarAis a global variable. That said, there is probably a better to do what you want to do.evalor varvars per se. If you are using a scripting language and don't ever utilize the one feature that separates it from compiled languages, you are doing it wrong. But if newcomers just resort to them because they don't want to learn about array syntax, that's just as dingy.