by petercooper · 2w ago · 0 comments
a=[5,3,1,4,2];b=[];a.map(n=>setTimeout(()=>b.push(n),n))
Obviously never use this for real, but I found it fun to think about the behavior and pitfalls of this algorithm in different languages.https://onlinegdb.com/VJ_0JKlQys
I thought of adding a timer to show it runs in a few ms but adding a timer would kind of defeat the purpose :)