* Our conditionals are always expressions! You can write let result = if a {"hello"} else {"bye"}
Destructuring
JavaScript
Us
const {a, b} = data
let {a, b} = data
const [a, b] = data
let [a, b] = data *
const {a: aa, b: bb} = data
let {a: aa, b: bb} = data
* Gives good compiler warning that data might not be of length 2.
Loop
JavaScript
Us
for (let i = 0; i <= 10; i++) {...}
for i in 0 to 10 {...}
for (let i = 10; i >= 0; i--) {...}
for i in 10 downto 0 {...}
while (true) {...}
while true {...}
JSX
JavaScript
Us
<Comp message="hi" onClick={handler} />
Same
<Comp message=message />
<Comp message /> *
<input checked />
<input checked=true />
No children spread
<Comp>...children</Comp>
* Argument punning!
Exception
JavaScript
Us
throw new SomeError(...)
raise(SomeError(...))
try {a} catch (Err) {...} finally {...}
try a catch { | Err => ...} *
* No finally.
Blocks
The last expression of a block delimited by {} implicitly returns (including function body). In JavaScript, this can only be simulated via an immediately-invoked function expression (since function bodies have their own local scope).
JavaScript
Us
let result = (function() {
const x = 23;
const y = 34;
return x + y;
})();