Syntax ExampleEdit it yourself
<script> // creat a variable var a, b, c; // use variable a = 5; b = 6; var c = a + b; document.getElementById("example").innerHTML = c; </script>
Anything written after a double slash
// (single line comment) or
/ * and
<script> // This is an example of a single line comment /* this example is multi line comment */ </script>
In the following example, a is defined as a variable. Then, 5 values are assigned
Arithmetic operators (
+, -, *, /) are used to calculate values and assignment operators (
=, + =,% =) are used to assign values to variables.
You cannot use keywords reserved by the rules as identifiers or property names.
Varkeyword browser variable can be understood from the following example: