REPL
REPL is the Node prompt: type node with no file. You try 2+2 and see 4. .exit to leave. Great for testing a one-liner. Not how you ship an API.
Trap — thinking REPL is the production server.
Exam tip
Type node, try 2+2, .exit.
Node.js · Theory
REPL is the Node prompt: type node with no file. You try 2+2 and see 4. .exit to leave. Great for testing a one-liner. Not how you ship an API.
Trap — thinking REPL is the production server.
Type node, try 2+2, .exit.
// REPL
const users = [
{ id: 1, name: "Asha" },
{ id: 2, name: "Ravi" },
];
function findUser(id) {
return users.find((u) => u.id === id) ?? null;
}
console.log(findUser(2));
console.log(users.map((u) => u.name));REPL: find user 2, then list names. Say both prints.