Backend Interview QA With Cover Sample
Backend Interview QA With Cover Sample
Page 1
Fullstack Backend Interview Q&A: Node.js, Express.js, MySQL, MongoDB
In Node.js, the event loop handles asynchronous operations. These three methods queue functions
differently:
- `process.nextTick()` queues the callback to be invoked after the current operation completes but before the
- `setImmediate()` queues the callback to be executed in the next iteration of the event loop (macrotask
queue).
- `setTimeout(fn, 0)` schedules the callback after a minimum delay of 0 ms, meaning it will be put in the timer
Use `nextTick` for code that must be executed immediately after the current function, and `setImmediate` for
- Use parameterized queries or prepared statements provided by libraries like `mysql2` or `sequelize`.
```js
connection.query('SELECT * FROM users WHERE username = ?', [username], function (err, results) {
// Safe query
});
```
Page 2