@@ -11,28 +11,28 @@ canonical: "/docs/manual/latest/overview"
11
11
12
12
### Semicolon
13
13
14
- | JavaScript | Us |
14
+ | JavaScript | ReScript |
15
15
| ------------------------------------ | -------------------- |
16
16
| Rules enforced by linter/formatter | No semicolon needed! |
17
17
18
18
### Comments
19
19
20
- | JavaScript | Us |
20
+ | JavaScript | ReScript |
21
21
| ----------------- | ----------- |
22
22
| ` /* Comment */ ` | Same |
23
23
| ` // Line comment ` | Same |
24
24
25
25
### Variable
26
26
27
- | JavaScript | Us |
27
+ | JavaScript | ReScript |
28
28
| ----------------------- | ------------------------------ |
29
29
| ` const x = 5; ` | ` let x = 5 ` |
30
30
| ` var x = y; ` | No equivalent (thankfully) |
31
31
| ` let x = 5; x = x + 1; ` | ` let x = ref(5); x := x.contents + 1 ` |
32
32
33
33
### String & Character
34
34
35
- | JavaScript | Us |
35
+ | JavaScript | ReScript |
36
36
| --------------------------| --------------------- |
37
37
| ` "Hello world!" ` | Same |
38
38
| ` 'Hello world!' ` | Strings must use ` " ` |
@@ -41,7 +41,7 @@ canonical: "/docs/manual/latest/overview"
41
41
42
42
### Boolean
43
43
44
- | JavaScript | Us |
44
+ | JavaScript | ReScript |
45
45
| ----------------------------------------------------- | ---------------------------------------------- |
46
46
| ` true ` , ` false ` | Same |
47
47
| ` !true ` | Same |
@@ -52,7 +52,7 @@ canonical: "/docs/manual/latest/overview"
52
52
53
53
### Number
54
54
55
- | JavaScript | Us |
55
+ | JavaScript | ReScript |
56
56
| ----------- | ------------ |
57
57
| ` 3 ` | Same \* |
58
58
| ` 3.1415 ` | Same |
@@ -64,7 +64,7 @@ canonical: "/docs/manual/latest/overview"
64
64
65
65
### Object/Record
66
66
67
- | JavaScript | Us |
67
+ | JavaScript | ReScript |
68
68
| ------------------- | --------------------------------------- |
69
69
| no types | ` type point = {x: int, mutable y: int} ` |
70
70
| ` {x: 30, y: 20} ` | Same |
@@ -74,7 +74,7 @@ canonical: "/docs/manual/latest/overview"
74
74
75
75
### Array
76
76
77
- | JavaScript | Us |
77
+ | JavaScript | ReScript |
78
78
| --------------------- | ---------------------------------- |
79
79
| ` [1, 2, 3] ` | Same |
80
80
| ` myArray[1] = 10 ` | Same |
@@ -84,15 +84,15 @@ canonical: "/docs/manual/latest/overview"
84
84
85
85
### Null
86
86
87
- | JavaScript | Us |
87
+ | JavaScript | ReScript |
88
88
| ------------------- | --------- |
89
89
| ` null ` , ` undefined ` | ` None ` \* |
90
90
91
91
\* Again, only a spiritual equivalent; we don't have nulls, nor null bugs! But we do have an ` option ` type for when you actually need nullability.
92
92
93
93
### Function
94
94
95
- | JavaScript | Us |
95
+ | JavaScript | ReScript |
96
96
| ------------------------------- | ---------------------------- |
97
97
| ` arg => retVal ` | Same |
98
98
| ` function named(arg) {...} ` | ` let named = (arg) => {...} ` |
@@ -130,7 +130,7 @@ canonical: "/docs/manual/latest/overview"
130
130
131
131
### If-else
132
132
133
- | JavaScript | Us |
133
+ | JavaScript | ReScript |
134
134
| --------------------- | ------------------------------------------------------------------- |
135
135
| ` if (a) {b} else {c} ` | ` if a {b} else {c} ` \* |
136
136
| ` a ? b : c ` | Same |
@@ -140,7 +140,7 @@ canonical: "/docs/manual/latest/overview"
140
140
141
141
### Destructuring
142
142
143
- | JavaScript | Us |
143
+ | JavaScript | ReScript |
144
144
| ----------------------------- | --------------------------------------------- |
145
145
| ` const {a, b} = data ` | ` let {a, b} = data ` |
146
146
| ` const [a, b] = data ` | <code >let [ a, b] = data</code > \* |
@@ -150,15 +150,15 @@ canonical: "/docs/manual/latest/overview"
150
150
151
151
### Loop
152
152
153
- | JavaScript | Us |
153
+ | JavaScript | ReScript |
154
154
| ------------------------------------- | ------------------------------ |
155
155
| ` for (let i = 0; i <= 10; i++) {...} ` | ` for i in 0 to 10 {...} ` |
156
156
| ` for (let i = 10; i >= 0; i--) {...} ` | ` for i in 10 downto 0 {...} ` |
157
157
| ` while (true) {...} ` | ` while true {...} ` |
158
158
159
159
### JSX
160
160
161
- | JavaScript | Us |
161
+ | JavaScript | ReScript |
162
162
| ----------------------------------------- | -------------------------- |
163
163
| ` <Comp message="hi" onClick={handler} /> ` | Same |
164
164
| ` <Comp message={message} /> ` | ` <Comp message /> ` \* |
@@ -169,7 +169,7 @@ canonical: "/docs/manual/latest/overview"
169
169
170
170
### Exception
171
171
172
- | JavaScript | Us |
172
+ | JavaScript | ReScript |
173
173
| ----------------------------------------------- | ------------------------------------------ |
174
174
| ` throw new SomeError(...) ` | ` raise(SomeError(...)) ` |
175
175
| ` try {a} catch (Err) {...} finally {...} ` | <code >try a catch { & #124 ; Err => ... } </code > \* |
0 commit comments