CoffeeScript, by design, does not allow you to obscure a previously declared variable. However, there is one case where this is still happening:
abc = -> a = 1 func = (a) -> a = 2 return func() alert(a) return
This will result in 1 . Since a is a function parameter, it is local to the scope.
By the way, you can rewrite this as
abc = -> a = 1 do (a) -> a = 2 alert a return
where do (a) -> a = 2 equivalent to ((a) -> a = 2)() .
source share