Difference between revisions of "Javascript Operators"
From Elite Wiki
Eric Walch (talk | contribs) (Added a list of javascrips operators) |
Eric Walch (talk | contribs) m (Layout change) |
||
Line 1: | Line 1: | ||
− | == Javascript | + | == Operators used in Javascript == |
Below is a listing of often used operators in javascript to help understand some of the used code in Oolite scripts. | Below is a listing of often used operators in javascript to help understand some of the used code in Oolite scripts. | ||
Line 45: | Line 45: | ||
'''Operator Description''' | '''Operator Description''' | ||
− | & Bitwise and | + | & Bitwise and<br> |
− | | Bitwise or | + | | Bitwise or<br> |
− | ^ Bitwise exclusive or (xor) | + | ^ Bitwise exclusive or (xor)<br> |
− | << Schift one bit to the left | + | << Schift one bit to the left<br> |
− | >> Schift one bit to the right | + | >> Schift one bit to the right<br> |
− | ~ Flip all bits (invert 0 to 1 and 1 to 0) | + | ~ Flip all bits (invert 0 to 1 and 1 to 0)<br> |
[[Category:Oolite scripting]] | [[Category:Oolite scripting]] |
Revision as of 19:21, 23 July 2009
Contents
Operators used in Javascript
Below is a listing of often used operators in javascript to help understand some of the used code in Oolite scripts.
Artithmetic Operators
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (remainder of a division)
++ Increment (++X means increment by one X before use and X++ means increment X after use
-- Decrement (--X means idecrement by one X before use and X-- means decrement X after use
Assignment Operators
Operator Description
= Assign
+= Add and assign. For example, x+=y is the same as x=x+y.
-= Subtract and assign. For example, x-=y is the same as x=x-y.
*= Multiply and assign. For example, x*=y is the same as x=x*y.
/= Divide and assign. For example, x/=y is the same as x=x/y.
%= Modulus and assign. For example, x%=y is the same as x=x%y.
Comparison Operators
Operator Description
== Is equal to
=== Is identical (is equal to and is of the same type)
!= Is not equal to
!== Is not identical
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
Logical/boolean Operators
Operator Description
&& and
|| or
! not
String Operators
In JavaScript, a string is simply a piece of text.
Operator Description
= Assignment
+ Concatenate (join two strings together)
+= Concatenate and assign
Bit Operators
Operator Description
& Bitwise and
| Bitwise or
^ Bitwise exclusive or (xor)
<< Schift one bit to the left
>> Schift one bit to the right
~ Flip all bits (invert 0 to 1 and 1 to 0)