Skip to main content

Operators, Constants and Literals

Operators

Operators are thing like plus + or minus - to perform operations on data. They follow the standard order of operations. E.g. multiplication is performed before addition and calculations in parenthesis ( ) are performed first.

OperatorComments
+ - * /standard math operators
()for controlling order of operations
||logical or. e.g. true || false === true
&&logical and. e.g. true && false === false
!logical not e.g. !true === false
? : Conditional (ternary) operator - The conditional (ternary) operator is the only operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy. This operator is like an if...else statement. For example:
(true ? "A" : "B") === "A"
(false ? "A" : "B") === "B"
==Type insensitive equality. Forgives differences in types. e.g. ("1" ==1) === true
===Type sensitive equality. Types matter. e.g. ("1"===1) === false
!=Type insensitive non-equality. Forgives differences in types. e.g. ("1" !=1) === false
!==Type sensitive non-equality. Types matter. e.g. ("1"!==1) === true
> >= < <=Greater than, greater than or equal, less than, less than or equal
, { } Separators. Commas , separate parameters to functions. Some functions use braces { } to group data elements
Constant or LiteralComments
12345.67Any constant number can be entered. can include exponential (e)
"text"Any text constant can be entered (use only double quotes "
trueboolean value of true
falseboolean value of false
undefinednot defined - identical to Javascript undefined
nullnull value - identical to Javascript null
0xffffhex literals '0' [xX] [0-9a-fA-F]
0o7777octal literals '0' [oO] [0-7]
0b1111binary literals '0' [bB] [0-1]