<script> var num = 7; var NUM = 4; document.write(num) </script>
A single line comment can be written by placing a text after putting double slash (//). Any text after // upto the end of the line would be treated as a single line comment.
There is also another way to write single line comments, that is by placing the text within <!– and //–>. This is somehow like commenting in HTML.
A multiline comment can be written by putting /* at the start of the comment and */ at the end of the comment.
<script> //This is a single line comment. <!--This is another single line comment//--> /*These are multiline comments. These are a combination of comments.*/ </script>
You can write your JS code in one line as well!
<script> var car = "santro";document.write(car); </script>
Arithmetic Operators: They are used to perform arithmetic operations on operands.
Assignment Operators: They are used to assign values to variables.
Comparison Operators: They are used to compare values of different variables.
<script> //x contain integer value var x = 10; //city contain string value var city = "Indore" //arr contain an array var arr = ['mango', 'apple', 'orange']; </script>
Primitive datatypes – integers/floats, strings, booleans, undefined and null.
Non-primitive datatypes – Objects, arrays and functions
The primitive types are stored by value whereas the non-primitive types are stored by reference.
Note : We shall see the topics such as variables, datatypes, functions, arrays in separate tutorials of this series.