Skip to content

Commit

Permalink
Add globalThis question
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheerj committed Sep 1, 2024
2 parents b549f8e + 6e8edf6 commit 19bdba0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8849,7 +8849,7 @@ The execution context is created when a function is called. The function's code
**[⬆ Back to Top](#table-of-contents)**
468. ### How to find the number of parameters expected by a function?
468. ### How to find the number of parameters expected by a function?
The function's object has a **length** property which tells you how many formal parameters expected by a function. This is a static value defined by the function, not the number of arguments the function is called with(__arguments.length__). The basic usage of length propery is,
```javascript
Expand Down Expand Up @@ -8905,18 +8905,18 @@ The execution context is created when a function is called. The function's code
2. In Node environment, you have to use `global`.
3. In Web workers, the global object is available through `self`.
The `globalThis` property provides a standard way of accessing the global object without writing various code snippet to support multiple environments. For example, the global object retuned from multiple environments as shown below,
```javascript
//1. browser environment
console.log(globalThis); // => Window {...}
The `globalThis` property provides a standard way of accessing the global object without writing various code snippet to support multiple environments. For example, the global object retuned from multiple environments as shown below,
```javascript
//1. browser environment
console.log(globalThis); // => Window {...}

//2. node.js environment
console.log(globalThis); // => Object [global] {...}
//2. node.js environment
console.log(globalThis); // => Object [global] {...}

//3. web worker environment
console.log(globalThis); // => DedicatedWorkerGlobalScope {...}
```
//3. web worker environment
console.log(globalThis); // => DedicatedWorkerGlobalScope {...}
```
**[⬆ Back to Top](#table-of-contents)**
<!-- QUESTIONS_END -->
Expand Down

0 comments on commit 19bdba0

Please sign in to comment.