Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Window Object
interview

Q1. What is the window object?
The Window Object represents the browser window and is the top-level global object in the browser environment.

All global variables, functions, and objects automatically become part of the window object. It provides methods and properties to control browser windows, alerts, timers, and user interactions.

Example
window.alert("Welcome to JavaScript");


Q2. Why is the Window Object important?
The Window Object is important because it provides access to browser-related features such as dialogs, timers, and page navigation.
It acts as the root object for all browser objects like document, location, and history.


Q3. Is it necessary to write 'window' before methods like alert() or console.log()?
No, it is not necessary.
Since the window object is global, its methods can be used directly.

Example
alert("Hello");
window.alert("Hello");

Both work the same.


Q4. What is alert() method?
The alert() method displays a popup message box with an OK button.

Example
alert("This is an alert message");


Q5. What is confirm() method?
The confirm() method displays a dialog box with OK and Cancel buttons and returns true or false based on user selection.

Example
let result = confirm("Are you sure?");
console.log(result);