JavaScript uses an event loop, an endless loop whereby the engine waits for tasks, executes them and wait for callbacks. In NodeJS, even though it's single-threaded, with this manoeuvre, you can perform non-blocking I/O operations. The one problem that arrises from this mechanism though, is that codes are not