Embedding – this is simply adding or embedding more code between an existing pair of <script> and </script> tag.
Let’s say you have a source code open in front of you – writing comments on the page will help notify other developers of what’s going on and where the project might need some additional help.
Comments work as follow: // is used for a single line comment and /*This is a multi-line comment*/
Using var variableName; let variableName; const variableName as keywords will help you define the performed action type.
If this sounds a bit confusing, just remember that you are creating the webpage, blog, or app and are essentially informing the web browser what variables it should create. Knowing what variable to placed where and how to insert it means you will be able to manipulate and create new web content. This is easy if you look at this example – let boy = football, meaning boy will be identified as a football. You can assign multiple variables, both identified and unidentified.
- Start variable names with a letter, underscore, or a dollar sign.
- Variable names cannot start with numbers and cannot contain spaces.
- Alpha-numeric characters (A-z and 0-9) and underscores are allowed.
Making use of functions
Because we write multiple blocks and lines of code, we can use functions that are designed to assist you in performing a single task. This means that your code will be split into different sections, making it easier to read, reuse, and perform a designated task.
To declare or show that a function may follow, you can use the keyword function before the desired function with brackets afterward.
String and number types
Beginners will most likely make use of Primitive Data types. These include string data types and number data types.
String Data Types: this is more focused on the arrangement of characters and represents textual data. Single or double quotes are used and surround one or more characters such as var a = ‘The dog barks’; // using single quotes, var b = “The dog barks”; // using double quotes.
Number Data Types: this data type focusses on the representation of numbers with its various properties i.e. decimal places, exponential notation, positive and negative, etc. Examples are, var a = 60; // integer, var b =230.99; // floating-point number.