Before we deep dive into global environment, let’s understand what objects are in Javascript.

In Javascript objects are simple a collection of name-value pairs, keep this important concept in mind.

For example name = 'John' Is a name/value pair

The Name might also contain other name/value pairs within it;

Name/Value pair image

		Name  
			Name 
				Name/Value  
				Name/Value  
				Name/Value  
			Name  
				Name/Value  
				Name/Value  
				Name/Value  
		Car:  
			{  
				Year:1922  
				Make: 'ABF'  
				Model: 'ALK'  
				Engine:  
					{  
						Cylinders: 25  
						Transmission: Auto  
					}  
			}  

ok 😊

Now, the Global environment is the base execution context in JavaScript. Global means, ACCESSIBLE anywhere and everywhere to your code.

Whenever your code is run, the javascript engine creates the global object and a variable this

To see this in action lets create a simple Javascript Code and then run it in Google chrome.

Open your terminal window and navigate to desktop, or to the directory you would like to create your projects in by typing cd then space followed by path to your directory

now create a new directory for this project. you can copy paste the following code into terminal and press enter.

Inside the directory, create a file and call it index.html Create another file and call it app.js Copy and paste the below html into index.html file

Now, the app.js file is empty, open up google crome then run your code by opening the index.html file in the chrome browser.

You can do this by simply draging the file into the browser window.

Go to the customize menu on the right and open.

Look for more tools then developer tools. Click on the developer tool to open the console.

The execution context ,global oject and the variable this were created.

to see that, simply type ‘this’ in the console and press enter.

you should see the Window object which then contains other objects.

“this” is the current window you are in.

But if you look inside the “this” you see that window is also an object. Now you can type window
in the console and you see what it in this global object.

There is always a global object when you run Javascript. In javaScript global means not inside a function

Home👈🏻

Next Lesson: GClick here👉🏽

Take one minute to let us know what you want us to cover here Here .

Connect on twitter Twitter.