Is there any counterpart for the following statement in JS:
foreach (['a'=>1,'b'=>2] as $k->$v) {
$$k=$v;
}
You may suggest the following code. But it declares the variables in the global scope.
for(k in {a: 1, b: 2})
{
window[k]=this[k];
}