
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a Global Object in JavaScript?
Objects in JavaScript are different from the Global Object. Using the new operator, you cannot create global objects. It comes into existence when the scripting engine is initialized. After it is initialized, the functions and constants are available for use.
A global object allows you to do the following −
It gives access to built-in functions and values. Call alert directly like the below code snippet, with window −
alert("Demo Text"); // or window.alert("Demo Text");
It also gives access to global function declarations and var variables −
<html> <head> <script> var str = "Demo Text"; // using window alert( window.str ); </script> </head> <body> </body> </html>
- Related Questions & Answers
- What is global namespace pollution in JavaScript?
- What is Global Scheduling?
- What is the role of global RegExp property in JavaScript?
- What is JavaScript object Destructuring?
- What is arguments object in JavaScript?
- What is math object in JavaScript?
- What is date object in JavaScript?
- What is WeakSet Object in JavaScript?
- What is the correct way to define global variables in JavaScript?
- What is the difference between global and local Variables in JavaScript?
- JavaScript global Property
- What is Math Object in JavaScript Program?
- What is a NaN property of a Number object in JavaScript?
- What is a composite data type i.e. object in JavaScript?
- What is a constructor to create String object in JavaScript?
Advertisements