
|
|
|||||||||||||||
JavaScript SyntaxLet's examine JavaScript's syntax. The syntax of any programming language refers to how the code instructions are written, and what certain symbols mean. Variables and data typesFirst, we need to take a look at a little more code. <script> This is another simple example of JavaScript. Here, we are using JavaScript variables. A variable can store information, and has a value. The value can change - which is why we call it a variable. When we want to refer to the value of that variable, we do not need to know the value of the variable, just the name of the variable, which makes it invaluable for development. Here, we take the variable Notice there are no quotes around our variable name Finally, there is a semicolon at the end of each line. This tells JavaScript where the end of an instruction is. Programming is about writing a series of instructions, and the semicolon shows where one instruction ends and another starts. All instructions should be on a seperate line, and we refer to each line as a statement, or, more commonly, a line of code. Arithmetic operatorsWe can add, subtract, multiply and divide numbers, and assign the result to variables, like so: total = 0; Here, we are operating on the variable Comparison operatorsWe will cover later the use of conditions and comparison operators. These comparison operators are used to compare two or more values, typically a variable and an absolute value. These are JavaScript's comparison operators:
So JavaScript syntax is really quite easy; keep practising and you can master it very quickly. Here's a summary of JavaScript syntax we've learned so far: variablename = 'New Value'; Now, let's take a closer look at variables.
|
||||||||||||||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |