The window Object — JS Technical Interview Questions & Answers

The global object in browser JavaScript.

The window Object

  • The window Object (js) is a JS topic. In plain words you use it for { name, marks } in a student record. Don’t start with a slogan — start with that picture.
  • Smallest example: const { name } = student. Type it, run it, and say what you see. If you can do that from memory, you know The window Object (js).
  • From the example next to this theory: The global object in browser JavaScript.
  • Trap: copying nested objects by accident (shallow copy). Fix that before you talk about advanced JS.
  • Viva: what is The window Object (js)? Then show const { name } = student. Then name the trap.

Technical Interview Tip: What is The window Object (js)? Show this: const { name } = student. Trap: copying nested objects by accident (shallow copy).

Code Examples for The window Object

The window Object — working example

// Browser BOM sketch (not available in Node/Piston):
// console.log(window.innerWidth, navigator.userAgent);
// location.assign("/prep"); history.back();

// Runnable stand-in:
const windowLike = { innerWidth: 1280, location: { href: "/home" }, history: [] };
windowLike.history.push(windowLike.location.href);
windowLike.location.href = "/prep";
console.log(windowLike.innerWidth, windowLike.location.href, windowLike.history);

The window Object — bOM APIs (window, navigator, location, history) talk to the browser chrome around the DOM.

How to Explain The window Object to an Interviewer

What is The window Object (js)?

Used for { name, marks } a student record Not just the heading

Give one small example of The window Object (js).

const { name } = student The global object in browser JavaScript

What mistake do beginners make with The window Object (js)?

copying nested objects by accident (shallow copy) Show the fix

Where do you use The window Object (js)?

a student record { name, marks }