thp/doc-generator/markdown/en/docs/latest/basics/operators.md
2023-03-28 19:18:06 -05:00

1.0 KiB

Operators

Misti has similar operators to JS.

Misti will enforce type checking in operators at compile time.
<p>
However, due to how JS works, automatic type casting may still occur if you combine the Misti output with JS.
</p>

Basic operators

4 + 2
4 - 2
4 * 2
4 / 2
4 % 2
4 ** 2

Asignment operators

i += 1
i -= 1
i *= 2
i /= 2
i %= 2
i **= 2

Bitwise operators

Not considered at the moment.

Comparison

1 == 2
1 != 2
1 > 2
1 < 2
1 >= 2
1 <= 2
In Misti there's only double equals `==`.
<br>
<br>
<code>x == y</code> will ALWAYS compile to <code>x === y</code>

Logical operators

true && false
true || false

!true
Multiple `!` are invalid, since there is no automatic type casting.
<br>
<br>
<code>!!</code> would be considered a different operator.
There is no short-circuit like so something like:
<br>
<br>
<code>true && "value"</code> will throw an error at compile time.