<script src=”script.js”></script>
Where you place this script tag will determine where your code is executed just like with placing your <script> tag. Likewise, you should be aiming to place your script reference at the bottom of your body for the best performance possible.
Just like with image files, your path to your script in the reference can be be either an absolute or a relative link.
JavaScript is a fantastic programming language, and what’s more, it’s actually fairly easy to pick up the basics relatively quickly. So let’s now take a look at how we structure our JavaScript.
A JavaScript statement is comprised of:
JavaScript values are simply pieces of data. Each value, or piece of data, has a type. That type defines the type of content that we are expecting. There are six different basic types for values. They are:
As you might have guessed, a value with a ‘number’ type is a value formed of a numerical value. They are written and displayed as you might expect, as numbers, such as ‘4231432’.
Strings are simply snippets of text. It could be a paragraph, a sentence, or even a single character. It is simply a snippet of text of any length.
A Boolean is a true/false value. It is usually used for evaluation of a statement. For example, 3<2 would render false, while 3>2 would render true as 3 is a larger number than 2.
These will be covered in more detail in the subsequent chapters.
Variables are what we use to store our data values. They are like buckets of information where we can store and modify the contents as we please. In JavaScript we use the keyword ‘var’ followed by a keyword and an equals sign to declare a variable, like so: