Starting JavaScript Part 1 - Main CharacteristicsThe Main Characteristics of JavaScript are:
Here we will go through and examine these characteristics in more detail Case SensitiveBecause JavaScript is case sensitive then: X=20 is not the same as x=20 and Newvar=20 Semi-colon UseJavaScript consists of two elements statements and comments. Anything that isn't a comment is interpreted as a statement. Statements an span more than one line or you can have multiple statements on a single line. The JavaScript interpreter will determine itself whether or not a statement has ended with or without the semi-colon; however using the semi-colon is the official way of telling the interpreter that the end of a statement has been reached. So although: x=20 both assign the value of 20 to the variable x, one uses the semi-colon the other doesn't, but they both work. It is good practise to always use the semi-colon as it makes your script far easier to read and debug. Using BracesBraces come in pairs: an opening brace (right brace).. { and a closing brace (left brace).. }. They are used for grouping statements together in blocks. They are typically used for functions and if/else test. For Example if (x==y) In the example if the x is equal to y then the block of true statements will be run if it is not the block of false statements will be run. Using Comments
Comments can be either single or multi line. A single line comment start with two backslashes e.g.
//This is a single line comment Multi-line comments start with /* and end with */ e.g.
/* valid
multi line comment */ /* Invalid comment as no end Invalid comment as no beginning */
|
||
|