Web Development · Foundations
JavaScript Fundamentals
On this page 9 sections
In 30 seconds
JavaScript source code is made from pieces that produce values and pieces that tell the engine to do something. An expression A unit of JavaScript code that evaluates to a value. Full entry →, such as 2 + 3, evaluates to a value A piece of data produced, represented, or used by JavaScript code. Full entry →. A statement A complete JavaScript instruction in program source text. Full entry →, such as an expression followed by a semicolon, is an instruction in the program. Values have types: familiar primitive A JavaScript value that is not an object, such as a string, number, Boolean, null, or undefined. Full entry → examples include strings, numbers, booleans, null, and undefined. Learning to identify these roles makes short programs easier to read and debug.
Why this matters
JavaScript is the programming language commonly used to add behavior to web pages, but its fundamentals matter before browser-specific work begins. Reading expressions and statements accurately helps a student predict what code will evaluate to, recognize a type mismatch, and locate an error without guessing. These concepts also transfer to later topics: variables give names to values, functions combine statements into reusable behavior, and browser APIs use the same expression-and-value model. This lesson stays deliberately below those later layers.
The college version
Values and their types
A value is a piece of data that JavaScript can work with. The language has several primitive value types: undefined, null, Boolean The JavaScript primitive type with the two values true and false. Full entry →, Number, BigInt, String, and Symbol. A primitive is a value that is not an object. At an introductory level, the most visible examples are numbers such as 12, strings such as "hello", Booleans true and false, and the special values null and undefined. These labels are not interchangeable. A number is suitable for arithmetic; a string represents text; a Boolean represents one of two logical states. null is an explicit primitive value often used to represent an intentional absence, whereas undefined is its own primitive value and commonly appears when no value has been supplied. Later lessons explain how names, collections, and objects hold or organize values; this lesson concentrates on the values themselves.
Type matters because an operator A symbol or keyword used in an expression to act on one or more operands. Full entry →'s behavior depends on its operands. 2 + 3 is numeric addition and produces the Number value 5. The comparison 2 < 3 produces the Boolean value true. A careful reader therefore asks both questions: what values are present, and what type of result should this operation produce? That habit is more reliable than reading punctuation as decoration. JavaScript can perform conversions in some situations, but relying on an unexamined conversion makes code harder to reason about. When a result surprises you, inspect the values and their types first.
Expressions evaluate
An expression is code that resolves to a value. A literal such as "Ada" is an expression: evaluating it yields that string. An arithmetic expression such as 6 * 7 evaluates to 42. Expressions can be combined. In 2 + 3 * 4, multiplication is evaluated before addition, so the resulting Number value is 14, not 20. Parentheses can deliberately change that grouping: (2 + 3) * 4 evaluates to 20. Executing these examples in a JavaScript runtime confirms the results.
Operators are symbols or keywords that participate in expressions. Arithmetic operators include +, -, *, and /. Comparison operators, including ===, <, and >, evaluate whether a relationship is true and yield a Boolean result. 5 === 5 evaluates to true; 5 === 6 evaluates to false. The strict equality operator compares without first converting the operands to a common type, which makes its result easier to predict than a loose equality check in many introductory cases. This lesson does not attempt to catalog every operator. The central model is that operators receive operands and an expression evaluates to one resulting value.
A result need not be displayed merely because an expression has a value. Interactive developer consoles often show the result of an entered expression as a convenience. That display is a feature of the host environment, not an implication that every expression automatically appears on a web page. Separating JavaScript language evaluation from browser output prevents a common early misunderstanding.
Statements organize actions
A statement is a complete instruction in a program. ECMAScript source text contains statements, and an expression statement is one familiar form: it evaluates an expression as an instruction. In many JavaScript examples, a semicolon marks the end of a statement. JavaScript has automatic semicolon insertion rules, but beginners should not treat omitted punctuation as a separate feature to depend on; clear formatting makes statement boundaries easier for humans to see. A program generally contains a sequence of statements, with each statement contributing to the program's behavior.
The expression/statement distinction is about role, not about which one is more advanced. 3 * 5 is an expression because it yields 15. Written as a standalone expression statement, it instructs the engine to evaluate that expression, though the completion value is not thereby made useful to a person. By contrast, a comment is not an instruction for the engine at all. JavaScript comments—// to the end of a line and /* ... */ across text—are ignored by the engine. They can record intent for future readers, but a comment cannot alter an evaluated result.
This vocabulary helps with debugging. If an expected result is wrong, inspect the expression: its operands, operator, precedence, and types. If intended work never occurs, inspect whether the necessary statement exists and is reached; control flow is a later topic. If only a comment describes an intended action, the engine will not carry it out. These distinctions remain useful as code becomes more complex, even though later lessons add variables, functions, arrays, objects, and web APIs.

Eli explains
The same idea, in plain words
Explain it like I’m 10
Imagine JavaScript as a tiny workshop. Values are the materials on the table: a number, a piece of text, or a yes/no card. An expression is a small calculation card. When the workshop reads 2 + 3, it works with two number materials and produces a new material, 5. A comparison card such as 2 < 3 produces a yes/no card: true.
A statement is closer to an instruction posted for the workshop: do this piece of work now. It can contain an expression, but the two words answer different questions. Ask “what value comes out?” for an expression and “what instruction is this?” for a statement. A comment is a sticky note for another person, not an instruction the workshop follows.
Picture it like this
Values are workshop materials, expressions are calculation cards that make a result, and statements are posted work instructions.
Where the picture stops working
Real JavaScript is formal language processing, not a person choosing materials. The analogy does not cover execution order, browser APIs, or how later code stores values.
Worked example
Run these expressions in a JavaScript console: 2 + 3 * 4 evaluates to 14, because multiplication groups before addition. (2 + 3) * 4 evaluates to 20, because the parentheses change the grouping. Next, 14 === 20 evaluates to the Boolean false; it compares two Number values and finds they differ. The first two snippets are arithmetic expressions that produce Number values. The third is a comparison expression that produces a Boolean. If each is entered as a standalone line, the console may show its result, but that display is the console helping the reader. A line comment such as // compare the two totals explains the next line to a human and has no evaluated value or effect on the calculation.
Key takeaway
Values have types, expressions evaluate to values, and statements organize program instructions. Naming the role of each piece of code makes JavaScript behavior more predictable.
Quick check
3 questions here, of 5 in this lesson’s practice set. Answers stay hidden until you check.
What does (2 + 3) * 4 evaluate to?
Which description best distinguishes an expression from a statement?
Study tools & related lessonsYou’ll learn to · Common mistakes · Easily confused · Key vocabulary · Related
You’ll learn to
- Define a JavaScript value, expression, and statement.
- Identify common primitive value types.
- Distinguish evaluation from an instruction that performs an action.
- Apply arithmetic and comparison operators to predict simple results.
Common mistakes
Calling every line of code an expression.
Ask whether the code's role is to produce a value; if it is a complete instruction, call it a statement.
Expecting a comparison to produce a number.
Comparison operators such as
<and===produce Boolean results.Assuming a console result is automatically page output.
A console may display evaluated values for convenience; displaying content in a page needs later browser APIs.
Treating
nullandundefinedas the same value.They are distinct JavaScript primitive values, even though both can arise in absence-related situations.
Easily confused
expression vs. statement
An expression evaluates to a value; a statement is a program instruction and may contain expressions.
number vs. Boolean
A number represents numeric data; a Boolean is either true or false.
comment vs. statement
A comment assists human readers and is ignored by the engine; a statement is processed as program source.
Key vocabulary
- value
- A piece of data produced, represented, or used by JavaScript code.
- primitive
- A JavaScript value that is not an object, such as a string, number, Boolean, null, or undefined.
- expression
- A unit of JavaScript code that evaluates to a value.
- statement
- A complete JavaScript instruction in program source text.
- operator
- A symbol or keyword used in an expression to act on one or more operands.
- operand
- A value or expression to which an operator is applied.
- Boolean
- The JavaScript primitive type with the two values true and false.
Sources & references
- MDN Web Docs — JavaScript data types and data structures — Mozilla / MDN Web Docs
- MDN Web Docs — Expressions and operators — Mozilla / MDN Web Docs
- ECMAScript Language Specification — Expressions — Ecma International / TC39
- ECMAScript Language Specification — Statements and declarations — Ecma International / TC39
- MDN Web Docs — JavaScript Guide: Grammar and types — Mozilla / MDN Web Docs
EliExplains lessons are original prose written from the open, credible references above. See Copyright & Licensing.
Researched 2026-08-20
Educational content only. It is not medical, legal or professional advice. Found an error? Tell us.

