-
-
Save AlexJWayne/c8329fdec424de9c57ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ary = [1..3] | |
# immediate 1 | |
# immediate 2 | |
# immediate 3 | |
for i in ary | |
console.log "immediate #{i}" | |
# functions 3 | |
# functions 3 | |
# functions 3 | |
fns = for i in ary | |
-> console.log "functions #{i}" | |
fn() for fn in fns | |
# functions with closure 1 | |
# functions with closure 2 | |
# functions with closure 3 | |
fns = for i in ary | |
do (i) -> | |
-> console.log "functions with closure #{i}" | |
fn() for fn in fns | |
# deferred 3 | |
# deferred 3 | |
# deferred 3 | |
for i in ary | |
setTimeout -> | |
console.log "deferred #{i}" | |
, 1000 | |
# deferred with closure 1 | |
# deferred with closure 2 | |
# deferred with closure 3 | |
for i in ary | |
do (i) -> | |
setTimeout -> | |
console.log "deferred with closure #{i}" | |
, 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment