monica_b1998@lemmy.world to Programming@programming.dev · 4 days agoAnimated particle constellations in 42 lines of JavaScriptslicker.meexternal-linkmessage-square8fedilinkarrow-up188arrow-down13cross-posted to: programming@programming.dev
arrow-up185arrow-down1external-linkAnimated particle constellations in 42 lines of JavaScriptslicker.memonica_b1998@lemmy.world to Programming@programming.dev · 4 days agomessage-square8fedilinkcross-posted to: programming@programming.dev
minus-squarebleistift2@sopuli.xyzlinkfedilinkEnglisharrow-up2·3 days agoIf you’re iterating over a whole array and need the index, like in ll.15f., you can instead write particles.forEach((particle, i) => { // loop body }) There may be a performance hit (I haven’t tested it) because you’re invoking a function on each iteration. And it’s mostly a stylistic choice.
If you’re iterating over a whole array and need the index, like in ll.15f., you can instead write
particles.forEach((particle, i) => { // loop body })There may be a performance hit (I haven’t tested it) because you’re invoking a function on each iteration. And it’s mostly a stylistic choice.