JavaScript Introduction
In this section, we will briefly introduce some basic JavaScript concepts, such as variables and functions. Different operators will be covered as we introduce them.
Loading JavaScript
JavaScript can either be inline in an HTML page or included from a separate JavaScript file. Both methods use the <script>
tag. With inline JavaScript, the JavaScript code is written directly inside the <script>
tags in an HTML file; for example, like this:
<script> // comments in JavaScript can start with // /* Block comments are also supported. This comment is multiple lines and doesn't end until we use a star then slash: */ let a = 5; // declare the variable a, and set its value to 5 console.log(a); // print a (5) to the browser console </script>
Note that the console.log
function...