javascript - Accessing Objects After 'x' in Array -


i have array alllayers trying access objects follow clicked a. how select every object follows clicked a?

alllayers = [] in [0...30]     card = new layer     alllayers.push(card)       in alllayers       a.on events.click, ->         ## how every object follows "a" in array?? 

thanks ideas.

consider

alllayers = new layer [0..30] alllayers.map (a,i) ->     a.on events.click, ->         remaining = alllayers[i+1..] 

it's worth noting using loops potentially sync actions bit dangerous.

settimeout((-> console.log(i)), 1000) in [1..10] 

and

[1..10].map (i) -> settimeout((-> console.log(i)), 1000) 

don't quite same thing due way scope works in javascript; functions introduce scope.


Comments