1

How to write a closure in livescript

for i from 1 to 10
  cb = -> console.log i
  set-timeout cb, i*1000

to get 1 to 10 instead of ten times 10 ?

toka
  • 128
  • 7

1 Answers1

5
for let i from 1 to 10
  cb = -> console.log i
  set-timeout cb, i*1000
Oleh Prypin
  • 33,184
  • 10
  • 89
  • 99
unclechu
  • 821
  • 10
  • 14