@@ -31,12 +31,12 @@ canonical: "https://rescript-lang.org/docs/manual/latest/overview"
31
31
32
32
### String & Character
33
33
34
- | JavaScript | Us |
35
- | --------------------------| --------------------- |
36
- | ` "Hello world!" ` | Same |
37
- | ` 'Hello world!' ` | Strings must use ` " ` |
38
- | ` "hello " + "world" ` | ` "hello " ++ "world" ` |
39
- | `` `hello ${message}` `` | Same |
34
+ | JavaScript | Us |
35
+ | --------------------------| ----------------------- |
36
+ | ` "Hello world!" ` | Same |
37
+ | ` 'Hello world!' ` | Strings must use ` " ` |
38
+ | ` "hello " + "world" ` | ` "hello " ++ "world" ` |
39
+ | `` `hello ${message}` `` | < code > { j & # 124 ; Hello $ ( message ) & # 124 ; j } </ code > |
40
40
41
41
### Boolean
42
42
@@ -57,7 +57,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/overview"
57
57
| ` 3.1415 ` | Same |
58
58
| ` 3 + 4 ` | Same |
59
59
| ` 3.0 + 4.5 ` | ` 3.0 +. 4.5 ` |
60
- | ` 5 % 3 ` | ` mod(5, 3) ` |
60
+ | ` 5 % 3 ` | ` 5 mod 3 ` |
61
61
62
62
\* JS has no distinction between integer and float.
63
63
@@ -75,7 +75,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/overview"
75
75
76
76
| JavaScript | Us |
77
77
| --------------------- | ---------------------------------- |
78
- | ` [1, 2, 3] ` | Same |
78
+ | ` [1, 2, 3] ` | ` [ | 1, 2, 3 | ] ` |
79
79
| ` myArray[1] = 10 ` | Same |
80
80
| ` [1, "Bob", true] ` | ` (1, "Bob", true) ` \* |
81
81
@@ -142,7 +142,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/overview"
142
142
| JavaScript | Us |
143
143
| ----------------------------- | --------------------------------------------- |
144
144
| ` const {a, b} = data ` | ` let {a, b} = data ` |
145
- | ` const [a, b] = data ` | <code >let [ a, b] = data</code > \* |
145
+ | ` const [a, b] = data ` | <code >let [ &# 124 ; a, b&# 124 ; ] = data</code > \* |
146
146
| ` const {a: aa, b: bb} = data ` | ` let {a: aa, b: bb} = data ` |
147
147
148
148
\* Gives good compiler warning that ` data ` might not be of length 2.
@@ -168,10 +168,10 @@ canonical: "https://rescript-lang.org/docs/manual/latest/overview"
168
168
169
169
### Exception
170
170
171
- | JavaScript | Us |
172
- | ----------------------------------------------- | ------------------------------------------ |
173
- | ` throw new SomeError(...) ` | ` raise(SomeError(...)) ` |
174
- | ` try {a} catch (Err) {...} finally {...} ` | <code >try a catch { & #124 ; Err => ... } </code > \* |
171
+ | JavaScript | Us |
172
+ | ----------------------------------------- | ------------------------------------------ |
173
+ | ` throw new SomeError(...) ` | ` raise(SomeError(...)) ` |
174
+ | ` try {a} catch (Err) {...} finally {...} ` | <code >try a catch { & #124 ; Err => ... } </code > \* |
175
175
176
176
\* No finally.
177
177
@@ -211,7 +211,7 @@ The last expression of a block delimited by `{}` implicitly returns (including f
211
211
Feature | Example | JavaScript Output
212
212
--------------------------------|--------------------------------------|----------------------
213
213
String | ` "Hello" ` | ` "Hello" `
214
- String Interpolation | `` ` Hello ${ message}` `` | ` "Hello " + message `
214
+ String Interpolation | < code > { j & # 124 ; Hello $ ( message ) & # 124 ; j } </ code > | ` "Hello " + message `
215
215
Character (disrecommended) | ` 'x' ` | ` 120 ` (char code)
216
216
Integer | ` 23 ` , ` -23 ` | ` 23 ` , ` -23 `
217
217
Float | ` 23.0 ` , ` -23.0 ` | ` 23.0 ` , ` -23.0 `
@@ -226,7 +226,7 @@ Boolean operation | `!`, `&&`, <code>||</code> | `!`, `&
226
226
Shallow and deep Equality | ` === ` , ` == ` | ` === ` , ` == `
227
227
List (disrecommended) | ` [1, 2, 3] ` | ` {hd: 1, tl: {hd: 2, tl: {hd: 3, tl: 0}}} `
228
228
List Prepend | ` [a1, a2, ...oldList] ` | ` {hd: a1, tl: {hd: a2, tl: theRest}} `
229
- Array | ` [ 1, 2, 3] ` | ` [1, 2, 3] `
229
+ Array | < code > [ &# 124 ; 1, 2, 3&# 124 ; ] </ code > | ` [1, 2, 3] `
230
230
Record | ` type t = {b: int}; let a = {b: 10} ` | ` var a = {b: 10} `
231
231
Multiline Comment | ` /* Comment here */ ` | Not in output
232
232
Single line Comment | ` // Comment here ` | Not in output
0 commit comments