Question : JS Object Key Variable?

var tool = 'something'

stack = { tool : 'data'}

it always returns key as "tool" instead of the value of "tool" which is "something"

im trying to accomplish the following in JS but here is a PHP example
$tool = "something";
$stack[$tool] = data;

i know its not pretty.....

Answer : JS Object Key Variable?

use :

1:
2:
3:
4:
var stack = {};
var tool = 'something';
stack[tool] = 'data';
//alert(stack.something);
Random Solutions  
 
programming4us programming4us