This question evaluates understanding of core frontend JavaScript concepts including the event loop and task scheduling, differences in variable scoping and hoisting (var/let/const), 'this' binding semantics, and HTML/CSS layout skills for constructing a 2x2 grid, falling under Software Engineering Fundamentals.
You are interviewing for a frontend JavaScript position. Answer the following conceptual and practical questions.
Explain how the JavaScript event loop works in a browser environment.
setTimeout
,
setInterval
, DOM events, etc.).
Promise.then
,
MutationObserver
, etc.).
var and letExplain the differences between var and let in JavaScript, focusing on:
Optionally, briefly contrast const with let as well.
this Binding in JavaScriptExplain how the value of this is determined in the following contexts:
Then describe at least three different ways to explicitly control or fix the value of this (for example, with bind, call, apply, storing this in another variable, using arrow functions, etc.), and give short code examples.
Using only HTML and CSS (no JavaScript), write markup and styles to draw a square that is divided into four equal smaller squares (a 2x2 grid), each with visible borders.
Provide the HTML and CSS code required.
Login required