JavaScript Statements: Expressions

An expression is a combination of values, variables, and operators, which computes to a value. The computation is called an evaluation. For example, 5 * 10 evaluates to a value of 50.
The script may look like this:
     <script>
         document.getElementById("demo").innerHTML = 5 * 10;
     </script>

Expressions can also contain variable values. For example, x can be assigned 5 and multiplied by the numberical 10, the value will become 50.
The script may look like this:
     <script>
         var x = 5;
         document.getElementById("demo").innerHTML = x * 10;
     </script>

The values can be of various types, such as numbers and strings. For example, "John" + " " + "Doe", evaluates to the value of John Doe.
The script may look like this:
     <script>
         document.getElementById("demo").innerHTML = "John" + " " + "Doe";
     </script>

Back Table of Contents Next