Node.js Syntax

Node executes JavaScript syntax. The language rules are the same in browser and server code, but the runtime APIs are different.

Statements and values

const appName = "node-lab";
let count = 1;
count += 1;
console.log(appName, count);

Language rules

  • Use semicolons consistently or choose one project style and keep it stable.
  • Prefer const when a name will not be reassigned.
  • Use strict naming for variables, functions, and modules.

Source structure

Keep top-level files small. Move reusable logic into modules, and keep I/O at the boundary.

Practice

  1. Write a script that prints three lines with console.log.
  2. Change one let to const and explain why it works or fails.
  3. Note one syntax rule that looks simple but changes code readability.