JSX

a faster, safer, easier JavaScript
Powered by Oktavia

Operators

The operators of JSX are the same to those in JavaScript (ECMA-262 3rd edition) except for the following changes.

The table below lists the operators supported by JSX.

Table 1. List of Operators by Precedence
OperatorReturned TypeOperand Type(s)
(x)[1] typeof x
func(...) return type of the function
obj.prop typeof obj.prop obj: any object type
array[index] Nullable.<T> array: Array.<T>
index: number
map[key] Nullable.<T> map: Map.<T>
key: string
x++
x--
typeof x number or int
obj instanceof type boolean obj: any object type
type: a Class, Interface, or Mixin
x as type[2]
x as __noconvert__ type[3]
type
++x
--x
typeof x number or int
+x
-x
typeof x number or int
~x int number or int
! x boolean any
typeof x string variant
x * y
x % y
number or int[4] number or int
x / y number number or int
x + y
x - y
number or int[4] number or int
x + y string string
x << y
x >> y
x >>> y
int number or int
x < y
x<= y
x > y
x >= y
boolean number, int, string[5]
x in y boolean x: string
y: Map.<T>
x == y
x != y
boolean any except variant[5]
x & y int number or int
x ^ y int number or int
x | y int number or int
x && y boolean any
x || y boolean any
x ? y : z typeof y any[6]
x ?: y typeof x any[5]
x = y typeof x any[7]
x op[8]= y typeof x same as op
x, y typeof y any
  1. grouping operator
  2. cast operator; in debug mode (i.e. unless --release or --disable-type-check is specified) raises an assertion failure when a invalid cast between object types are detected
  3. cast operator (simply changes the type of the value recognized by the compiler)
  4. int is returned if both operands are int
  5. types of x and y should be equal, or either should be convertible to the other
  6. types of y and z should be equal, or either should be convertible to the other
  7. type of y should be convertible to type of x
  8. any of: * / % + - << >> >>> & ^ |