Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could be to allow use of local variables that do not leak into the scope this code is executed in. That's what I use this pattern for.


pro tip: no longer necessary

    { let count = 50; const interval = setInterval(() => { addSnakeNode(); if (--count <= 0) clearInterval(interval); }, 100) }


And polluting the global variable namespace hardly matters when using the console.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: