3 ms·
I really appreciate how Haxe (which targets js) handles this situation. If you want to write js, and stick with block level scoping, it's a great option.
by jdonaldson 14y ago
I really appreciate how Haxe (which targets js) handles this situation. If you want to write js, and stick with block level scoping, it's a great option.
var k = 1;
var foo = function(){
var k = 2;
var foo = function(){
if (Math.random() > .5){
var k = 3;
}
trace(k);
};
}
[...]
("transpiles" to)
[...]
var k = 1;
var foo = function() {
var k1 = 2;
var foo1 = function() {
if(Math.random() > .5) {
var k2 = 3;
}
console.log(k1);
};
};