LiveScript do closure not working

231 views Asked by At
a = 5
do (a) ->
    console.log a

Why does this compile to

a = 5;
(function(a){
  return console.log(a);
})();

a is not passed in so it is undefined. Am I doing self executing closure wrong?

1

There are 1 answers

0
Ven On BEST ANSWER

In LiveScript, do just invokes a function. You're looking for let :

let a
  console.log a