Message from JavaScript discussions

June 2019

— Http://!!!PGJ1dHRvbj5DbGljayBtZSE8L2J1dHRvbj4%3D

Message permanent page


I suggest everyone to please go through the above link, which describes "how JavaScript's call stack, event loop, and callback queue interact with each other. Visualizing the javascript runtime at runtime"

— Yesterday, I gone through those article. Awesome exploration by Philip Roberts :)

— Why does this happen

— It has always worked

— Let's say file has 4 chars
i = file.length
i will be 4
file[4] // undefined

— You should do:
let i = file.length - 1

— Because file[3] is the highest accessible int when file has length 4

— But it says nothing abouut the index variable

— Nope, it doesn't, and it shouldn't try to

— File[4] is undefined, you're passing undefined to process.stdout.write

— So do i need to roll a dice to guess what do i need to fix?