You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -106,6 +105,25 @@ Use [caniuse](https://caniuse.com/) to check what browser support the feature yo
106
105
107
106
You can then use "polyfills" (or "shims") to support older browser. There are some polyfills for each specific feature, and some other that includes lots of polyfills (e.g. [zloirock/core-js](https://github.com/zloirock/core-js#ecmascript-array)).
108
107
108
+
Polyfills are different from transpiling. Babel is a transpiler, you
109
+
can see how it work online here:
110
+
111
+
For instance, it will translate:
112
+
113
+
```javascript
114
+
[1, 2, 3].map((n) => n +1)
115
+
```
116
+
117
+
Into:
118
+
119
+
```javascript
120
+
"use strict";
121
+
122
+
[1, 2, 3].map(function (n) {
123
+
return n +1;
124
+
});
125
+
```
126
+
109
127
### Undefined everywhere!
110
128
111
129
```javascript
@@ -175,6 +193,17 @@ dog + 1 + "a"
175
193
dog - 1
176
194
```
177
195
196
+
Other gotchas:
197
+
198
+
```javascript
199
+
// NaN is fun!
200
+
console.assert(typeof NaN === "number");
201
+
Object.is(NaN, NaN) // true
202
+
NaN === NaN // false
203
+
```
204
+
205
+
A good talk on the topic: [Wat](https://www.destroyallsoftware.com/talks/wat)
206
+
178
207
#### Always use triple comparators (`===`) instead of double (`==`)
179
208
180
209
```javascript
@@ -219,6 +248,9 @@ const source = { b: 2};
219
248
constmerged=Object.assign(target, source);
220
249
console.assert(_.isEqual(merged, {a:1, b:2});
221
250
251
+
// Spread operator
252
+
constmerge2= {...target, ...source};
253
+
222
254
// Array.includes (ES7)
223
255
consttheArray= [1, 2]
224
256
console.assert(theArray.includes(1))
@@ -234,6 +266,8 @@ The book [JavaScript: The Good Parts](https://www.oreilly.com/library/view/javas
234
266
235
267
> You make prototype objects, and then … make new instances. Objects are mutable in JavaScript, so we can augment the new instances, giving them new fields and methods. These can then act as prototypes for even newer objects. We don't need classes to make lots of similar objects… Objects inherit from objects. What could be more object oriented than that?
236
268
269
+

270
+
237
271
Some good articles:
238
272
239
273
- [A Plain English Guide to JavaScript Prototypes](http://sporto.github.io/blog/2013/02/22/a-plain-english-guide-to-javascript-prototypes/)
0 commit comments