본문 바로가기

Programming/JavaScript

Statements and Expressions

A JavaScript program is a sequence of statements.

Each statement is an instruction for the computer to do something.

 

vs.

 

An expression is a bit of JavaScript code that produces a value.

1 → produces 1
"hello" → produces "hello"
5 * 10 → produces 50
num > 100 → produces either true or false
isHappy ? "🙂" : "🙁" → produces an emoji
[1, 2, 3].pop() → produces the number 3

 

https://www.joshwcomeau.com/javascript/statements-vs-expressions/

 

Statements Vs. Expressions

One of the most foundational things to understand about JavaScript is that programs are made up of statements, and statements have slots for expressions. In this blog post, we'll dig into how these two structures work, and see how building an intuition abo

www.joshwcomeau.com