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
constwhen 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
- Write a script that prints three lines with
console.log. - Change one
lettoconstand explain why it works or fails. - Note one syntax rule that looks simple but changes code readability.