Operators: differences from JS

Rook — 1.0 specification

Rook JS Note
a == b a === b the language has no loose comparison
a != b a !== b
x == null x == null stays loose: catches both null and undefined
a = b, a += b the same only as a statement: f(a = 1), a = b = c are errors
i++, i-- the same only as a statement: a = i++ is an error; no ++i
&&, ||, ! the same only for bool; a default value is written with ??
a + b the same numbers or strings; "a" + 1 is an error, use a template
x as T x the types must be related, see below
delete obj.key the same only as a statement, see below

The rest is as in JS: arithmetic, comparisons, bitwise operations, **, ??, ?., ? :, typeof, instanceof, new, spread ..., indexing xs[i].

The language has no var, function, ===, while, do...while, for...in, with or comma operator.

Only a function call or new can be a statement on its own, as in Go: a line a + b or user.name by itself is an error. This catches typos and a line break before a binary operator:

const total = price
    + tax              // error: there is already a ; after price, and "+ tax" does nothing

Markdown source on GitHub