@@ -55,54 +55,55 @@ interchangeably. For example, `x+y` will always evaluate identically to
5555Functions below.
5656
5757
58- Operator | Name | Syntax | Associativity | Example | Result
59- ----------- | -------------------------- | ---------- | ------------- | --------------------- | ---------------
60- ` ( ` , ` ) ` | Grouping | ` (x) ` | None | ` 2 * (3 + 4) ` | ` 14 `
61- ` [ ` , ` ] ` | Matrix, Index | ` [...] ` | None | ` [[1,2],[3,4]] ` | ` [[1,2],[3,4]] `
62- ` { ` , ` } ` | Object | ` {...} ` | None | ` {a: 1, b: 2} ` | ` {a: 1, b: 2} `
63- ` , ` | Parameter separator | ` x, y ` | Left to right | ` max(2, 1, 5) ` | ` 5 `
64- ` . ` | Property accessor | ` obj.prop ` | Left to right | ` obj={a: 12}; obj.a ` | ` 12 `
65- ` ; ` | Statement separator | ` x; y ` | Left to right | ` a=2; b=3; a*b ` | ` [6] `
66- ` ; ` | Row separator | ` [x; y] ` | Left to right | ` [1,2;3,4] ` | ` [[1,2],[3,4]] `
67- ` \n ` | Statement separator | ` x \n y ` | Left to right | ` a=2 \n b=3 \n a*b ` | ` [2,3,6] `
68- ` + ` | Add | ` x + y ` | Left to right | ` 4 + 5 ` | ` 9 `
69- ` + ` | Unary plus | ` +y ` | Right to left | ` +4 ` | ` 4 `
70- ` - ` | Subtract | ` x - y ` | Left to right | ` 7 - 3 ` | ` 4 `
71- ` - ` | Unary minus | ` -y ` | Right to left | ` -4 ` | ` -4 `
72- ` * ` | Multiply | ` x * y ` | Left to right | ` 2 * 3 ` | ` 6 `
73- ` .* ` | Element-wise multiply | ` x .* y ` | Left to right | ` [1,2,3] .* [1,2,3] ` | ` [1,4,9] `
74- ` / ` | Divide | ` x / y ` | Left to right | ` 6 / 2 ` | ` 3 `
75- ` ./ ` | Element-wise divide | ` x ./ y ` | Left to right | ` [9,6,4] ./ [3,2,2] ` | ` [3,3,2] `
76- ` % ` | Percentage | ` x% ` | None | ` 8% ` | ` 0.08 `
77- ` % ` | Addition with Percentage | ` x + y% ` | Left to right | ` 100 + 3% ` | ` 103 `
78- ` % ` | Subtraction with Percentage| ` x - y% ` | Left to right | ` 100 - 3% ` | ` 97 `
79- ` % ` ` mod ` | Modulus | ` x % y ` | Left to right | ` 8 % 3 ` | ` 2 `
80- ` ^ ` | Power | ` x ^ y ` | Right to left | ` 2 ^ 3 ` | ` 8 `
81- ` .^ ` | Element-wise power | ` x .^ y ` | Right to left | ` [2,3] .^ [3,3] ` | ` [8,27] `
82- ` ' ` | Transpose | ` y' ` | Left to right | ` [[1,2],[3,4]]' ` | ` [[1,3],[2,4]] `
83- ` ! ` | Factorial | ` y! ` | Left to right | ` 5! ` | ` 120 `
84- ` & ` | Bitwise and | ` x & y ` | Left to right | ` 5 & 3 ` | ` 1 `
85- ` ~ ` | Bitwise not | ` ~x ` | Right to left | ` ~2 ` | ` -3 `
86- <code >| ; </code > | Bitwise or | <code >x | ; y</code > | Left to right | <code >5 | ; 3</code > | ` 7 `
87- <code >^| ; </code > | Bitwise xor | <code >x ^| ; y</code > | Left to right | <code >5 ^| ; 2</code > | ` 7 `
88- ` << ` | Left shift | ` x << y ` | Left to right | ` 4 << 1 ` | ` 8 `
89- ` >> ` | Right arithmetic shift | ` x >> y ` | Left to right | ` 8 >> 1 ` | ` 4 `
90- ` >>> ` | Right logical shift | ` x >>> y ` | Left to right | ` -8 >>> 1 ` | ` 2147483644 `
91- ` and ` | Logical and | ` x and y ` | Left to right | ` true and false ` | ` false `
92- ` not ` | Logical not | ` not y ` | Right to left | ` not true ` | ` false `
93- ` or ` | Logical or | ` x or y ` | Left to right | ` true or false ` | ` true `
94- ` xor ` | Logical xor | ` x xor y ` | Left to right | ` true xor true ` | ` false `
95- ` = ` | Assignment | ` x = y ` | Right to left | ` a = 5 ` | ` 5 `
96- ` ? ` ` : ` | Conditional expression | ` x ? y : z ` | Right to left | ` 15 > 100 ? 1 : -1 ` | ` -1 `
97- ` ?? ` | Nullish coalescing | ` x ?? y ` | Left to right | ` null ?? 2 ` | ` 2 `
98- ` : ` | Range | ` x : y ` | Right to left | ` 1:4 ` | ` [1,2,3,4] `
99- ` to ` , ` in ` | Unit conversion | ` x to y ` | Left to right | ` 2 inch to cm ` | ` 5.08 cm `
100- ` == ` | Equal | ` x == y ` | Left to right | ` 2 == 4 - 2 ` | ` true `
101- ` != ` | Unequal | ` x != y ` | Left to right | ` 2 != 3 ` | ` true `
102- ` < ` | Smaller | ` x < y ` | Left to right | ` 2 < 3 ` | ` true `
103- ` > ` | Larger | ` x > y ` | Left to right | ` 2 > 3 ` | ` false `
104- ` <= ` | Smallereq | ` x <= y ` | Left to right | ` 4 <= 3 ` | ` false `
105- ` >= ` | Largereq | ` x >= y ` | Left to right | ` 2 + 4 >= 6 ` | ` true `
58+ Operator | Name | Syntax | Associativity | Example | Result
59+ ----------- |-----------------------------|-------------| ------------- |-----------------------| ---------------
60+ ` ( ` , ` ) ` | Grouping | ` (x) ` | None | ` 2 * (3 + 4) ` | ` 14 `
61+ ` [ ` , ` ] ` | Matrix, Index | ` [...] ` | None | ` [[1,2],[3,4]] ` | ` [[1,2],[3,4]] `
62+ ` { ` , ` } ` | Object | ` {...} ` | None | ` {a: 1, b: 2} ` | ` {a: 1, b: 2} `
63+ ` , ` | Parameter separator | ` x, y ` | Left to right | ` max(2, 1, 5) ` | ` 5 `
64+ ` . ` | Property accessor | ` obj.prop ` | Left to right | ` obj={a: 12}; obj.a ` | ` 12 `
65+ ` ; ` | Statement separator | ` x; y ` | Left to right | ` a=2; b=3; a*b ` | ` [6] `
66+ ` ; ` | Row separator | ` [x; y] ` | Left to right | ` [1,2;3,4] ` | ` [[1,2],[3,4]] `
67+ ` \n ` | Statement separator | ` x \n y ` | Left to right | ` a=2 \n b=3 \n a*b ` | ` [2,3,6] `
68+ ` + ` | Add | ` x + y ` | Left to right | ` 4 + 5 ` | ` 9 `
69+ ` + ` | Unary plus | ` +y ` | Right to left | ` +4 ` | ` 4 `
70+ ` - ` | Subtract | ` x - y ` | Left to right | ` 7 - 3 ` | ` 4 `
71+ ` - ` | Unary minus | ` -y ` | Right to left | ` -4 ` | ` -4 `
72+ ` * ` | Multiply | ` x * y ` | Left to right | ` 2 * 3 ` | ` 6 `
73+ ` .* ` | Element-wise multiply | ` x .* y ` | Left to right | ` [1,2,3] .* [1,2,3] ` | ` [1,4,9] `
74+ ` / ` | Divide | ` x / y ` | Left to right | ` 6 / 2 ` | ` 3 `
75+ ` ./ ` | Element-wise divide | ` x ./ y ` | Left to right | ` [9,6,4] ./ [3,2,2] ` | ` [3,3,2] `
76+ ` % ` | Percentage | ` x% ` | None | ` 8% ` | ` 0.08 `
77+ ` % ` | Addition with Percentage | ` x + y% ` | Left to right | ` 100 + 3% ` | ` 103 `
78+ ` % ` | Subtraction with Percentage | ` x - y% ` | Left to right | ` 100 - 3% ` | ` 97 `
79+ ` % ` ` mod ` | Modulus | ` x % y ` | Left to right | ` 8 % 3 ` | ` 2 `
80+ ` ^ ` | Power | ` x ^ y ` | Right to left | ` 2 ^ 3 ` | ` 8 `
81+ ` .^ ` | Element-wise power | ` x .^ y ` | Right to left | ` [2,3] .^ [3,3] ` | ` [8,27] `
82+ ` ' ` | Transpose | ` y' ` | Left to right | ` [[1,2],[3,4]]' ` | ` [[1,3],[2,4]] `
83+ ` ! ` | Factorial | ` y! ` | Left to right | ` 5! ` | ` 120 `
84+ ` & ` | Bitwise and | ` x & y ` | Left to right | ` 5 & 3 ` | ` 1 `
85+ ` ~ ` | Bitwise not | ` ~x ` | Right to left | ` ~2 ` | ` -3 `
86+ <code >| ; </code > | Bitwise or | <code >x | ; y</code > | Left to right | <code >5 | ; 3</code > | ` 7 `
87+ <code >^| ; </code > | Bitwise xor | <code >x ^| ; y</code > | Left to right | <code >5 ^| ; 2</code > | ` 7 `
88+ ` << ` | Left shift | ` x << y ` | Left to right | ` 4 << 1 ` | ` 8 `
89+ ` >> ` | Right arithmetic shift | ` x >> y ` | Left to right | ` 8 >> 1 ` | ` 4 `
90+ ` >>> ` | Right logical shift | ` x >>> y ` | Left to right | ` -8 >>> 1 ` | ` 2147483644 `
91+ ` and ` | Logical and | ` x and y ` | Left to right | ` true and false ` | ` false `
92+ ` not ` | Logical not | ` not y ` | Right to left | ` not true ` | ` false `
93+ ` or ` | Logical or | ` x or y ` | Left to right | ` true or false ` | ` true `
94+ ` xor ` | Logical xor | ` x xor y ` | Left to right | ` true xor true ` | ` false `
95+ ` = ` | Assignment | ` x = y ` | Right to left | ` a = 5 ` | ` 5 `
96+ ` ? ` ` : ` | Conditional expression | ` x ? y : z ` | Right to left | ` 15 > 100 ? 1 : -1 ` | ` -1 `
97+ ` ?? ` | Nullish coalescing | ` x ?? y ` | Left to right | ` null ?? 2 ` | ` 2 `
98+ ` ?. ` | Optional chaining accessor | ` obj?.prop ` | Left to right | ` obj={}; obj?.a ` | ` undefined `
99+ ` : ` | Range | ` x : y ` | Right to left | ` 1:4 ` | ` [1,2,3,4] `
100+ ` to ` , ` in ` | Unit conversion | ` x to y ` | Left to right | ` 2 inch to cm ` | ` 5.08 cm `
101+ ` == ` | Equal | ` x == y ` | Left to right | ` 2 == 4 - 2 ` | ` true `
102+ ` != ` | Unequal | ` x != y ` | Left to right | ` 2 != 3 ` | ` true `
103+ ` < ` | Smaller | ` x < y ` | Left to right | ` 2 < 3 ` | ` true `
104+ ` > ` | Larger | ` x > y ` | Left to right | ` 2 > 3 ` | ` false `
105+ ` <= ` | Smallereq | ` x <= y ` | Left to right | ` 4 <= 3 ` | ` false `
106+ ` >= ` | Largereq | ` x >= y ` | Left to right | ` 2 + 4 >= 6 ` | ` true `
106107
107108
108109## Precedence
0 commit comments