The external file must be ASCII text with the file extension .js. Do not use the beginning and ending tags in the external
|Boolean||bTest = true;||A logical value that is either true or false.|
|Number||nNum = 32;||An integer or floating-point value.|
|String||strString = “hello”;||A string of characters.|
A variable that is not assigned a value is type NULL;
– variable names are case sensitive.
– To define a hexadecimal number, prefix the number with 0x.
– You can use single or double quotation marks to enclose a string value.
– If a variable is a string type and you want to use it in a mathematical operation, use the built-in function ParseInt() or ParseFloat() to convert the string to a number.
strNum = "32"; strDen = "2.5"; nQuotient = ParseInt(strNum) / ParseFloat(strDen);
– If a variable is type Number and you want to use it in a string, use the toString() method.
nNum = 15.5; strNum = nNum.toString();
<html> <header></header> <body> <h1>Hello!</h1> </body> </html>
<script>//Your code goes here</script>
<script> alert("Hello!"); </script>
The alert method accepts a string between quotation marks inside the brackets. You can enter a literal string, as shown above, or you can enter the name of a string variable. When you use the name of a string
variable you don’t need the quotation marks. You can use the procedure described above to experiment with the examples provided in this tutorial.