JavaScript
Tips to write a script for a web page:
- It is best to keep JavaScript code in its own Javascript file
- Using <\script> to load the JavaScript file, <\link> is for a CSS file
- Writing comments to explain your code
- Declaring the variable before using it
- There are three types of variables:
- Numeric data type
- String data type
- Boolean data type
Rules for naming variables:
- The name must begin with a letter, dolar sign, or an underscore, it must not not start with a number
- The name can contain letters, numbers, dollar sign, or an underscore, but must not use a dash or a period
- Cannot use keywords or reserved words, like var
- All variables are case sensitive
- Use a name that describes the kind of information that the variable stores
- Use a capital letter for the first letter of every word after the first word, if the variable name is made up of more than one word