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
Copy file name to clipboardExpand all lines: README.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -412,3 +412,22 @@ console.log(newCarColor)
412
412
413
413
//You can use this syntax today using @babel/plugin-proposal-optional-chaining
414
414
```
415
+
416
+
# globalThis
417
+
```javascript
418
+
Accessing theglobal propertyin JavaScript has always posed somedifficulty.This is because
419
+
different platforms have different ways to access it.
420
+
421
+
Client-side JavaScript useswindow orself
422
+
423
+
Node.js usesglobal
424
+
425
+
Web workers useself
426
+
427
+
TheglobalThis property provides a standard wayof accessing theglobal'this' value acrossenvironments.you can access theglobal objectin a consistent manner without having to know which environment the code is being runin.
428
+
429
+
console.log(globalThis)//get the global this depends on your environment