Essential JavaScript

Going Further

Expressions

A JavaScript expression is anything that resolves to a value. We all know 1 + 2 = 3. The expression 1 + 2 resolves to 3. Similarly, 6 - 2 resolves to 4.

There are other types of expressions and values than numbers, but numbers make for easy examples.

When you log an expression with console.log in the practice editor, you will see the result of the expression after it is evaluated. So instead of 1 + 1, you would just see 2.

Multiple Expressions

Try logging these three expressions with console.log. Just run the code that is already in the practice editor:

1 + 2 3 + 5 - 1 55 / 11

Notice how the result of each expression is logged to the console, rather than the expression itself.

Learning Goals

  • I know generally what an expression is

  • I can give examples of a few math expressions in JavaScript

  • I know what happens if I pass an expression to console.log

Code Editor

Click "Run Code" to execute your JavaScript in a secure sandbox and see the output below.

Console Output

// Console output will appear here...

0 output lines