Identifiers
Names for variables, functions and properties. Example: itemCount.
JavaScript syntax is the grammar of the language: values, variables, expressions, statements, blocks, strings, punctuation and readable formatting.
const name = "User A";
const tasks = 4;
if (tasks >= 3) {
console.log(`${name} is making progress.`);
}
JavaScript Basics
JavaScript is case-sensitive. name, Name and NAME are three different identifiers. Small spelling and punctuation details matter.
A program is made from expressions and statements. Expressions produce values. Statements perform actions, declare things or control flow.
Readable syntax is not only about making the browser happy. It is about making the next developer understand your intent quickly.
Names for variables, functions and properties. Example: itemCount.
Values written directly in code. Example: 42, "hello", true or [].
Code that produces a value. Example: price * quantity.
Code between curly braces that groups statements together.
Examples
const itemPrice = 12;
const itemCount = 5;
const total = itemPrice * itemCount;
if (total > 50) {
console.log("Large cart estimate");
}
let x=12,y=5,z=x*y;if(z>50){console.log("ok")}
const ItemPrice = 12;
console.log(itemPrice); // Different name, error
Rules that matter
JavaScript becomes much easier when you understand why a pattern exists. The syntax is only the surface; the real skill is choosing the right behavior for the interface.
itemPrice is more useful than x when the code grows.
One capital letter can create a completely different identifier.
Use const when a binding will not be reassigned. Use let when it will.
Curly braces show which statements belong together.
Indentation and spacing help humans read code.
JavaScript has automatic semicolon insertion, but consistent semicolons avoid confusing edge cases.
Production thinking
Syntax is the first gate. If JavaScript cannot parse your code, nothing else matters. If humans cannot read it, maintaining it becomes slow and risky.
A syntax error can stop all scripts on a page, including scripts that control accessible navigation, validation or feedback.
Use formatting and linting tools in production projects. They keep style consistent and catch many mistakes early.
A syntax error in critical JavaScript can break content, internal links or rendered UI. That can affect crawling and user behavior.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read the topic. Change the code, explain what happened and answer the questions in your own words.