LiveScript do closure not working

217 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 best solutions below

0
On BEST ANSWER

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

let a
  console.log a