The 'skill-check' JS quiz

Published: (March 3, 2026 at 10:36 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Question 1: Type coercion

What does the following code output to the console?

console.log(0 == '0');
console.log(0 === '0');

Answer: true, then false

Explanation: Search for “JavaScript Type Coercion” to understand why == performs type conversion while === does not.

Question 2: Arrow function this

In the snippet below, what will be logged?

const user = {
  name: 'Alex',
  greet: () => {
    console.log(`Hi, I'm ${this.name}`);
  }
};

user.greet();

Answer: Hi, I'm undefined (or an empty string in some environments)

Explanation: Arrow functions inherit this from the surrounding lexical scope (the global object or module), not from the object they’re defined on. Use a regular function expression to access user.name.

Question 3: var vs let in asynchronous loops

What is the result of this execution?

for (var i = 0; i  console.log(i), 1);
}

Answer: 3, 3, 3

Explanation: var is function‑scoped, so the loop finishes before the setTimeout callbacks run, leaving i at 3. Replacing var with let would log 0, 1, 2 because let creates a new binding for each iteration.

Question 4: Array reference behavior

What happens to list2?

let list1 = [1, 2, 3];
let list2 = list1;
list1.push(4);

console.log(list2.length);

Answer: 4

Explanation: Arrays are objects passed by reference. list2 is not a copy; it points to the same underlying array as list1.

Question 5: typeof null

What is typeof null?

Answer: "object"

Explanation: This is a long‑standing quirk from the first version of JavaScript that remains for backward compatibility.

0 views
Back to Blog

Related posts

Read more »

TaskTimer

Overview I’m currently building TaskTimer, a lightweight and minimal task timer web app with a mobile version coming soon designed to help users track daily ta...