Answers for "global object in javascript"

9

javascript global object

//Access Global variable
var foo = "foobar";
foo === window.foo; // Returns: true


//Accessing Global Functions
function greeting() {
   console.log("Hi!");
}

window.greeting();
Posted by: Guest on August-18-2021
-1

global object in javascript

var x = {name: "John"};	// This is a global object
for(let i=0; i<10; i++){
  	// Variable x is alive here
	// Variable i is alive here
  	
  	let a = 3;
  	// Variable a is alive here
  	
  	var y = 0;
  	// Variable y is alive here
}
// Variable i is dead here
// Variable a is dead here
// Variable x is alive here
// Variable y is alive here
console.log(x);	// {name: "John"}
console.log(y); // 0
Posted by: Guest on May-14-2021

Code answers related to "global object in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language