How to write a closure in livescript?

112 Views Asked by At

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 ?

1

There are 1 best solutions below

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