Skip to content

Commit 180d108

Browse files
committed
global objects notes
1 parent 922cd2b commit 180d108

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Global Objects
2+
3+
In browsers, the top-level scope is the global scope. That means that in browsers if you're in the global scope var something will define a global variable. In Node.JS this is different. The top-level scope is not the global scope; `var something` inside a Node.JS module will be local to that module.
4+
5+
Node. js global objects are global in nature and they are available in all modules. We do not need to include these objects in our application, rather we can use them directly. These objects are modules, functions, strings and object itself.
6+
7+
There are built-in objects that are part of the JavaScript language itself, which are also globally accessible. [refer them here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) and [here](https://nodejs.org/api/globals.html#global-objects)
8+
9+
The following variables may appear to be global but are not.
10+
11+
```
12+
__dirname
13+
__filename
14+
exports
15+
module
16+
require()
17+
```

0 commit comments

Comments
 (0)