Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Strong JavaScript interview answers do two things: predict what a short program does and explain why. The 20 concepts below give you the mental models for scope, functions, objects, promises and scheduling. For each one, practice saying the rule, tracing a tiny example, and naming the caveat (especially when a browser or Node.js host is involved).

1. Strict equality (===)

Strict equality compares values without performing the coercions used by abstract equality. If the operands have different types, === normally returns false; if they have the same type, the language compares according to that type’s rules.

0 === false   // false
'7' === 7     // false
7 === 7       // true

Use === as the default in application code because the conversion step is explicit rather than surprising. Interview-ready explanation: “Strict equality does not apply abstract-equality coercion, so both type and value must match.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Abstract equality (==)

== follows JavaScript’s abstract-equality algorithm. In several cases it converts one operand before comparing, which is why expressions can produce results that look inconsistent when you have not traced the conversion.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
0 == false    // true
'7' == 7      // true
null == undefined // true

The operator is part of the language, not an error, but an interview answer should identify the conversion instead of calling it “the same as” ===. If a codebase deliberately uses a documented coercion rule, explain that policy; otherwise choose strict equality for predictability.

3. Object identity

Objects are compared by identity, not by recursively comparing their properties. Two separately created objects with the same shape are still different references.

const first = { id: 1 };
const second = { id: 1 };
first === second // false

const alias = first;
first === alias   // true

This matters when checking whether a value changed in a state update or when using an object as a Map key. To compare contents, write an explicit, domain-appropriate comparison rather than expecting === to do a deep comparison.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Function scope with var

A var declaration is scoped to the containing function (or to the global script context when declared at top level), not to a block such as an if or for body.

function demo() {
  if (true) {
    var message = 'ready';
  }
  return message; // 'ready'
}

That wider scope can let a name leak out of a block and can create one shared binding in a loop. In modern code, reserve var for situations where its function-scoped behavior is intentional.

5. Block scope with let and const

let and const create bindings limited to the nearest block. A let binding may be reassigned; a const binding may not be reassigned, although an object stored in a const variable can still be mutable.

if (true) {
  let count = 1;
  const label = 'items';
}
// count and label are not accessible here

Block scope makes the lifetime of loop variables and temporary names easier to reason about. It also gives each loop iteration its own binding in the common for (let i = ...) form.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Hoisting is declaration instantiation, not moving text

“Hoisting” is a shorthand for how JavaScript creates bindings before executing the statements in a scope. The engine does not literally rearrange your source file. Different declarations have different initialization behavior, which is what you observe at runtime.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
console.log(value); // undefined
var value = 3;

The var binding exists when the log runs and starts with undefined; the assignment happens later. Describe the observable phases—binding creation, initialization and assignment—instead of saying the line was physically moved upward.

7. The temporal dead zone

A let or const binding also exists from the start of its block, but it is uninitialized until execution reaches its declaration. Reading it earlier throws a ReferenceError; this interval is called the temporal dead zone (TDZ).

console.log(total); // ReferenceError
let total = 3;

The TDZ catches accidental use-before-initialization. It is different from an undeclared name (which also fails) and from a hoisted var (which reads as undefined).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

8. Lexical environments and scope lookup

JavaScript resolves an identifier through the lexical environment created by the surrounding source structure. A nested function first checks its own bindings, then the enclosing environment, continuing outward until it finds a match or reaches the global environment.

const theme = 'dark';
function show() {
  const prefix = 'UI';
  return prefix + ':' + theme;
}
show(); // 'UI:dark'

Because this relationship is determined by where code is written, not by which object happens to call it, JavaScript is lexically scoped. That rule is the foundation for closures.

9. Closures preserve access to bindings

MDN Web Docs defines a closure as “the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).” A function can therefore keep using an outer binding after the outer function has returned.

function makeCounter() {
  let count = 0;
  return () => ++count;
}

const next = makeCounter();
next(); // 1
next(); // 2

The closure retains access to the binding, not a frozen snapshot of every value. If the binding changes, later calls observe the new value. This is useful for callbacks, private state and factories.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

10. Callbacks are values passed for later execution

A callback is simply a function supplied to another function so it can be invoked later or when an operation completes. The receiving API decides when and with what arguments to call it.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
function doubleLater(number, done) {
  done(number * 2);
}

doubleLater(4, result => {
  console.log(result); // 8
});

When explaining a callback, separate the function value from the call: pass done, but call done() only inside the operation. Callbacks often close over surrounding variables, and asynchronous callbacks are scheduled by the host or by a promise mechanism rather than running immediately at the registration line.

11. Regular-function this follows the call form

For an ordinary function, this is determined by how the function is called. A method call supplies the object to the left of the dot; extracting the function and making a plain call removes that receiver.

const user = {
  name: 'Mina',
  greet() { return this.name; }
};

user.greet();        // 'Mina'
const greet = user.greet;
greet();             // plain-call behavior; no user receiver

In strict mode, a plain call has this as undefined; non-strict behavior and host wrappers can differ. Always state the call site, strictness and host when predicting a result.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

12. Arrow functions use lexical this

An arrow function does not create its own this. It reads this from the surrounding lexical context, so changing the call form of the arrow does not rebind it.

const panel = {
  label: 'Settings',
  start() {
    const read = () => this.label;
    return read();
  }
};
panel.start(); // 'Settings'

Use arrows when you want the surrounding receiver in a callback. Use a regular method or function when the function should receive a receiver from its caller.

13. Prototype lookup delegates to other objects

Every ordinary object can have a prototype. When a property is not found as an own property, JavaScript continues looking on that object’s prototype and then up the prototype chain.

const base = { kind: 'base' };
const item = Object.create(base);
item.name = 'sample';

item.name; // 'sample' (own property)
item.kind; // 'base' (found on prototype)

The chain is delegation for property lookup, not a copy of properties into each object. A missing property remains undefined after the chain is exhausted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

14. Own properties versus inherited properties

An own property is stored directly on the object. An inherited property is supplied by a prototype. This distinction matters when enumerating data, validating input or deciding whether an object has a field itself.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Object.hasOwn(item, 'name'); // true
Object.hasOwn(item, 'kind'); // false
'kind' in item;              // true (own or inherited)

Use an own-property check when inherited names should not count. The in operator intentionally includes the prototype chain.

15. Class syntax sits on the prototype model

JavaScript class syntax offers a compact way to define constructors and methods, but it does not replace prototypes. Instance methods declared in a class are placed on the constructor’s prototype and are shared through lookup.

class Account {
  constructor(owner) {
    this.owner = owner;
  }
  describe() {
    return this.owner;
  }
}

const account = new Account('Lee');
account.describe(); // 'Lee'

In an interview, connect the two views: class syntax is authoring convenience; the runtime still uses objects, prototypes and delegation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

16. A promise represents a future result

A promise represents an asynchronous operation that is pending, then settles as fulfilled or rejected. Consumers register reactions rather than blocking the JavaScript agent while the operation completes.

const result = fetchData(); // returns a promise
result.then(value => {
  console.log(value);
});

Promise settlement is one-way: a settled promise cannot become pending again or switch from fulfillment to rejection. The value or reason becomes available to handlers attached with then and catch.

17. Promise chaining and error handling

then returns another promise, so each handler can return a value for the next step or return a promise that the chain adopts. A rejection can be handled with catch, which also returns a promise for subsequent work.

loadUser()
  .then(user => loadOrders(user.id))
  .then(orders => render(orders))
  .catch(error => showError(error));

Returning the inner operation is the key difference between a connected chain and a callback that starts work without telling the outer chain when it is finished.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

18. An async function always returns a promise

Marking a function async wraps its eventual result in a new promise. Returning a non-promise value fulfills that promise with the value; throwing causes rejection.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
async function answer() {
  return 42;
}

answer().then(value => console.log(value)); // 42

This remains true even when the function body contains no await. Callers should therefore consume an async function with await or promise handlers.

19. await, sequencing and concurrency

Inside an async function, await suspends the rest of that function until the awaited promise settles; it does not block unrelated JavaScript from running. A surrounding try/catch can handle a rejection.

async function readProfile() {
  try {
    const response = await request('/profile');
    return response.data;
  } catch (error) {
    report(error);
  }
}

Where you place await controls when work starts. These calls are sequential because the second starts after the first fulfills:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const one = await getOne();
const two = await getTwo();

Start independent operations first when they can overlap, then combine their outcomes:

const onePromise = getOne();
const twoPromise = getTwo();
const [one, two] = await Promise.all([onePromise, twoPromise]);

Promise.all fulfills when every input fulfills and rejects when one rejects. Use Promise.allSettled when you need each outcome, including failures. MDN cautions that separately awaiting promises held in an array can create rejection-handling pitfalls; choose an explicit combinator for the intended policy.

20. Call stack, jobs, tasks and microtasks

The JavaScript engine executes active code on a call stack. The host—such as a browser or Node.js—provides timers, network operations and other environment APIs. Once the current stack is empty, queued jobs can run. Exact event-loop behavior is host-defined, so do not present one browser diagram as a universal rule for every runtime.

In the browser-oriented model documented by MDN, promise reactions are microtasks and timer callbacks are tasks. The microtask queue is drained before the event loop takes the next task.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
console.log('A');
setTimeout(() => console.log('timer'), 0);
Promise.resolve().then(() => console.log('promise'));
console.log('B');

The usual browser result is A, B, promise, then timer: synchronous statements finish first, the resolved-promise reaction runs as a microtask, and the timer callback waits in the task queue. Explain each queue and the host assumption when answering.

A practical interview rehearsal

  1. Predict before running. Write the output, thrown error or returned promise state for a snippet.
  2. Trace bindings and call sites. Mark each scope, closure capture, receiver for this and prototype lookup.
  3. Trace asynchronous boundaries. Identify what is synchronous, what returns a promise, where await suspends, and which host queue receives a callback.
  4. State one caveat. Mention strict mode, object identity, a TDZ, a host-specific scheduling detail or the difference between sequential and concurrent work when it affects the answer.
  5. Use a one-sentence rule. Finish with a concise explanation such as “The arrow inherits lexical this,” or “The promise reaction is a microtask drained before the timer task.”

This routine turns memorized definitions into the reasoning interviewers are looking for: an accurate prediction, a trace that another developer can follow, and a qualification that prevents overclaiming.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.