java script dynamic varibale creation

Java
<script> 
    var k = 'value'; 
    var i = 0; 
    for(i = 1; i < 5; i++) { 
        eval('var ' + k + i + '= ' + i + ';'); 
    } 
    console.log("value1=" + value1); 
    console.log("value2=" + value2); 
    console.log("value3=" + value3); 
    console.log("value4=" + value4); 
</script> 

Source

Also in Java: