Search Tutorials
CommentsComments are helpful lines that are not compiled.
There are two types.
OperatorsOperators are signs that do something to variables on either side of them. Here are the arithmetic operators:
The Modulus operator(%) computes the remainder of division between 2 integers. var x = 3; var y = 5; var mult1 = x * y; trace(x + " times " + y + " = " + mult1);ex2 var min = 35; var max = 239; var addition = min + max; trace(min + " plus " + max + " = " + addition;You get the idea. Try all the operators and start writing your own scripts. Equality, Relational and Logical OperatorsThese operators evaluate to true or false Logical AND (&&)
Evaluates to true only if both its operands evaluate to true. E.g.
x = 5;
if(x>0 && x <10){
something = true;
}
trace(something);
BOTH MUST BE TRUE.
Logical OR ( || )Evaluates to true if either of its operands evaluate to true. E.g.
x = 5;
If(x>0 || x<4){
something = true;
}
trace(something);
EITHER CAN BE TRUE
Assignment Operator ( = )The effect that an assignment has is to store a new value in the left operand's associated memory storage space e.g. x = 7;This statement means that the value 7 is assigned to the variable x. Increment and decrement Operators ( ++ and -- )
The increment (++) and decrement (--) operators are a shortcut way of adding or subtracting 1 from a variable. E.g. stack[++top] = val; //Is equivalent to the following 2 lines top = top +1; stack[top] = val;The postfix form of ( --) decrements the value of top after that value is used. stack[top--] = val; //Is equivalent to : stack[top] = v; top = top -1;
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|