Can CoffeeScript Be Translated into This Piece of JavaScript?
- by tangrui
function abc() {
var a = 1;
var func = function() {
var a = 2;
}
func();
alert(a);
}
Pay attention to the var, in the piece of code, the result of a will be 1, but if the var is omitted, the result will be 2, but I found Coffee not able to translate to this.
For example the following:
abc = ->
a = 1
func = ->
a = 2
return
func()
alert(a)
return