Code Talk #023: Expressions, Values, Operators, and Statements - Recap
July 06, 2021
An expression is a representation of a value. A value is a specific piece of information which can categorized into one of the following data types: string, boolean, number, function, array, object, symbol, undefined, or null. For example the value 10 is a number and the value 'hello world' is a string. Values can be expressed in much more complicated ways by pairing them with operators, which are symbols governing the interaction between one or more values. For example the binary plus operator '+' reduces two number values to a single number value representing their sum (Note: if those values are strings, then they are concatenated together to form a single string). The value 4 can therefor be represented as (2 + 2). There are a multitude of other operators which behave in distinct ways depending on the data types of the values involved. Some common ones are OR (||), AND (&&), LESS THAN (<), GREATER THAN (>), etc. The most important characteristic of an expression/value is that it can be stored and passed around as a variable. Without values and expressions, a program would not be able to meaningfully represent information in the real world.
A statement by itself doesn't contain information, it represents a process. Unlike expressions and values, a statement cannot be stored as a variable and passed around. Some common statements are IF/ELSE, SWITCH, FOR, and VAR/CONST/LET. Statements are incredibly important because they provide the logical infrastructure for how a program executes. Without statements, programs would merely be fancy manipulations of values.