Fire-House 58

logic

logic

b-3


JavaScript:
gascripts.com Variables, Control Structures & Operators

 

Hard Reload
To See Menu

Variables...

are names assigned to JavaScript statements. They may contain any letter, numeral or the _ underscore character, but may not contain any of JavaScript's reserved words. They are case sensitive.Variables must be declared within the script. This can be done by simply stating a value for the variable, or using the reserved word var.

legal variables illegal variables initializing variables
myVariable my Variable var myVariable
mytest_ my*test var mytest_ = new Array()
duck DUCK-Fart duck = document.forms[0].elements[0].value

A variables scope is determined by where it is declared. Variables that are declared outside of any functions are global, and can be used by any function. Variables declared within a function are local to that function, and child functions nested within it.

Control Structures...

provide the backbone of performing JavaScript operations. They instruct your script how to perform the task it is given. These structures take on decision making and looping.

Control Structures
conditional

substitute for if...else for simple decisions.

conditional control structures

if...else 

evaluates conditions and provides instructions if condition is met.

if...else control structures
for loops

creates a cycle to evaluate a condition multiple times.

for loop control structures
while loops

creates a cycle to to evaluate a condition becomes false.

while loop control structure

 

Object Manipulation Statements
for...in loop through a single object
label labels a statement
new creates a new instance of an object
this specifies the current object
switch...case to test an object for multiple conditions

 

Operators
 
Arithmetic +, -, *, /, %, ++, --, -   
Assignment =, +=, -=, *=,/=, %=  
Bitwise and(&), or( | ), or(^), <<, >>>, >>  
Comparison ==, !=, >, <, >=, <=  
Boolean &&, ||, !  
 
[back]   [home]   [next]