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
//Async is more useful when you really don't care when the script loads and nothing else that is user dependent depends upon that script loading.(for scripts likes Google analytics)
417
417
<script async src="myscript.js"></script>
418
418
419
-
//With defer, browser will run your script when the page finished parsing. (not necessary finishing downloading all image files.
419
+
//With defer, browser will run your script when the page finished parsing. (not necessary finishing downloading all image files.
420
420
<script defer src="myscript.js"></script>
421
421
```
422
422
@@ -454,16 +454,16 @@ console.log(carColor);
454
454
//Now this new optional chaining operator will let us be even more fancy:
455
455
456
456
constnewCarColor= car?.name?.color;
457
-
console.log(newCarColor)
457
+
console.log(newCarColor)
458
458
//undefined- no error
459
-
459
+
460
460
//You can use this syntax today using @babel/plugin-proposal-optional-chaining
461
461
```
462
462
463
463
**[⬆ Back to Top](#table-of-contents)**
464
464
### globalThis
465
465
```javascript
466
-
Accessing the global property in JavaScript has always posed some difficulty. This is because
466
+
Accessing the global property in JavaScript has always posed some difficulty. This is because
467
467
different platforms have different ways to access it.
468
468
469
469
Client-side JavaScript uses window or self
@@ -472,7 +472,7 @@ Node.js uses global
472
472
473
473
Web workers use self
474
474
475
-
The globalThis property provides a standard way of accessing the global'this' value across environments. you can access the global object in a consistent manner without having to know which environment the code is being run in.
475
+
The globalThis property provides a standard way of accessing the global'this' value across environments. you can access the global object in a consistent manner without having to know which environment the code is being run in.
476
476
477
477
console.log(globalThis) //get the global this depends on your environment
478
478
@@ -596,7 +596,7 @@ observer.observe(image);
596
596
```
597
597
598
598
**[⬆ Back to Top](#table-of-contents)**
599
-
### Notify when element size is changed
599
+
### Notify when element size is changed
600
600
see our codepen: https://codepen.io/JSsnippets/pen/dyYoYVX
601
601
```javascript
602
602
constfoo=document.getElementById("foo");
@@ -620,10 +620,10 @@ see our codepen: https://codepen.io/JSsnippets/pen/gOapPzq
0 commit comments