I am attempting to make a simple while (true) {} loop, but it waits 1 second before running the code inside it. Basically, I want a system something like this:
Hello, world! (waits 1 second) Hello, world! (waits 1 second) Hello, world! (waits 1 second) Hello, world! (waits 1 second) Hello, world! (waits 1 second) and so on.
But I keep on receiving this error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
My code:
while (true) {
setTimeout(() => {
console.log(`Hello, world!`)
}, 1000);
}
Thanks in advance!