DEV Community

Discussion on: How I made a live code editor with Vanilla Javascript?

Collapse
 
hepisec profile image
hepisec

It shouldn't matter because the code is sent to the client and is not evalled. So the client would freeze itself if it enters while (1) {}

Collapse
 
loucyx profile image
Lou Cyx

.... it still matters. If you're writing while(value) { and said value starts as a truthy and you were planning to set it to falsy inside that while, you'll never be able to do that because the editor will freeze before that. You write infinite loops all the time, you just write the logic to stop them after, if an editor renders as soon as you write, it will freeze. It should ideally show an error as editors like CodeSandbox, CodePen or StackBlitz do.