Versions Compared
Version | Old Version 3 | New Version 4 |
---|---|---|
Changes made by | ||
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Tables
Table of Contents | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Operators
Item | Description |
+ Addition | Add two variables together to get the result. Example: 3 + 4 The result will be 7. |
- Subtraction | Subtract one variable from another to get the result. Example: 7 - 3 The result will be 4. |
* Multiplication | Multiply one variable to another to get the result. Example: 3 * 4 The result will be 12. |
/ Division | Divide one variable from another to get the result. Example: 7/7 The result will be 1. |
% Modulus | This will grab the remainder from the division of two variables. Example: 4/3 The result will be 1. |
&& Logical AND | If the two variables being compared are true, it will return true. If one or both are false, it will return false. Example: If A = true, and B = false A && B will result in false. |
|| Logical OR | If one of the two variables being compared are true, it will return true. If both are false, it will return false. Example: If A = true, and B = false A || B will result in true. |
! Logical NOT | Returns the logical inverse of the variable. Example: If A = true !A will result in false. |
< Less Than | Will return true if the first variable is less than the second one, and will return false if not. Example: A = 3, B = 4 A < B will result in true. |
> Greater Than | Will return true if the first variable is greater than the second one, and will return false if not. Example: A = 3, B = 4 A > B will result in false. |
<= Less than or Equal to | Will return true if the first variable is less than OR equal to the second one, and will return false if not. Example: A = 4, B = 4 A <= B will result in true. |
>= Greater than or Equal to | Will return true if the first variable is less than OR equal to the second one, and will return false if not. Example: A = 5, B = 7 A >= B will result in false. |
== Equal to | Will return true if both variables are equal to each other, and will return false if not. Example: A = 5, B = 5 A == B will result in true. |
=== Instance of | Will return true if both variables are equal to each other and are the same type, and will return false if not. Example: A = 1, B = '1' A === B will result in false. |
!= Not equal to | Will return true if both variables are not equal to each other, and will return false if not. Example: A = 2, B = 3 A != B will result in true. |
in In | Will check if the specific property exists within an object. Example: myObj = {a: 1, b: 2, c: 3}; if ('a' in myObj) { This will result in “Property “a” " “a" exists in myObj being executed. |
= Assignment | Will initialized initialize a value to a variable. Example: A = 5 A will now equal 5 when called. |
+= Addition Assignment | Adds to the number specified to the variable to its current value. Example: A = 5; A+= 2; A will result in 7. |
-= Subtraction Assignment | Subtracts the number specified to the variable from its current value. Example: A = 5; A -= 2; A will now equal 3. |
*= Multiplication Assignment | Multiplies to the number specified to the variable to its current value. Example: A = 5; A *= 2; A will now equal 10. |
/= Division Assignment | Divides the number specified to the variable from by its current value. Example: A = 5; A *= 2; A will now equal 10. |
++ Increment Operator | Adds one to the variable. Example: A = 2; A++; A will now equal 3. |
-- Decrement Operator | Subtracts one from the variable. Example: A = 2; A--; A will now equal 1. |
~ Bitwise invert | Will invert every bit of the variable. Example: A = 3 (0000 0000 0000 0011) A = ~A; A will bits will now be 1111 1111 1111 1100, which is equal to 65532. |
& Bitwise AND | Bitwise logical AND calculation of two variables. Example: A = 3, B = 4 A & B This will result in 0. |
| Bitwise OR | Bitwise logical OR calculation of two variables. Example: A = 3, B = 4 A | B This will result in 7. |
^ Bitwise XOR | Bitwise logical XOR calculation of two variables. Example: A = 3, B = 4 A ^ B This will result in 7. |
<< Bitwise Shift Left | Shifts the Bits of the first variable to the left dependant on the bits of the 2nd variable. Fills bits using 0 Example: A = 2, B = 5 A << B This will result in 64. |
>> Bitwise Shift Right (Signed) | Shifts the Bits of the first variable to the right dependant on the bits of the 2nd variable. Fills bits using a copy of the leftmost bit. Example: A = 2, B = 5 A >> B This will result in 0. |
>>> Bitwise Shift Right (Zero Filling) | Shifts the Bits bits of the first variable to the right dependant dependent on the bits of the 2nd variable. Fills bits using 0. Example: A = 2, B = 5 A >>> B This will result in 0. |
typeof | Will return the data type of the variable. Example: A = 2; typeof A; Will result in “number”a "number". |
void | Evaluates a specific instruction , but will always return undefined. Used when an expression is used to perform an action without the need for a return instruction. Example: void function foo() { This will have a an undefined return value of undefined. |
new | Used to create a new instance of a user-created object, Date, or Array types. Example: var oldTime = new Date("Dec 31 1999"); The two dates will create a new instance , while displaying their own data. |
delete | Deletes a property from an object. Example: This will remove the first name from a resident. var resident = { notification.send(JSON.stringify(resident)); delete resident.firstName; notification.send(JSON.stringify(resident)); |
, | Takes both expressions, evaluates them in order, and returns the one on the right. Can It can be used to take multiple actions during a for loop. Example: var s = ""; |
?…: | Checks if a statement is false. In the format of Example: var isOn = tag.read("checkLight"); |
Keywords
Item | Description |
| The if statement executes instructions if the condition is true. Otherwise, it will run the else statement to run a different set of instructions . Else else if can be used to specify a different set of instructions with different conditions. |
| Will repeatedly execute while the condition is true. Will It will stop once it becomes false. |
| Will allow you execute with the contents of a while loop once before the condition is evaluated. While the condition is true, it will keep executing until the condition it becomes false, exactly the same as like a normal while loop. |
| A for loop will repeat a set number of times until the specified condition becomes false. |
| Terminates a while loop, for loop, or switch statement completely. This will prevent execution of any following cases or loops. |
| Terminates the running of the current iteration in a loop, then runs the next one. |
| Allows users to compare an input value to the value of each case. If the case matches, it will run the code for that case. IF If no cases match, a default case will be run. |
| The code that will run in the event that if no cases are matched in a switch statement. |
| Block of code that is designed to perform a specific action or task |
| Ends the function execton execution and will return the specified value. |
| Can be used within a function to get values that were passed into the function. |
| Allows users to execute a block of code which that might not run successfully, ; if it does fail, a catch block will be able to handle it in the event of a failure. |
| Throws an error object, which will end ending the script with a popup error. Can It can be used within a try block so that it can to be tested with without interfering with the rest of the project. |