‘skill-check’ JS 퀴즈

발행: (2026년 3월 4일 오전 12:36 GMT+9)
2 분 소요
원문: 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: “JavaScript Type Coercion”을 검색하면 ==는 타입 변환을 수행하고 ===는 수행하지 않는 이유를 이해할 수 있습니다.

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: 화살표 함수는 주변 렉시컬 스코프(전역 객체 또는 모듈)에서 this를 상속받으며, 정의된 객체에서 this를 가져오지 않습니다. 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는 함수 스코프이므로 루프가 setTimeout 콜백이 실행되기 전에 끝나고 i3이 됩니다. var 대신 let을 사용하면 각 반복마다 새로운 바인딩이 생성되어 0, 1, 2가 출력됩니다.

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: 배열은 참조에 의해 전달되는 객체입니다. list2는 복사본이 아니라 list1과 같은 내부 배열을 가리킵니다.

Question 5: typeof null

What is typeof null?

Answer: "object"

Explanation: 이는 JavaScript 최초 버전에서 발생한 오래된 특이점이며, 하위 호환성을 위해 현재까지 유지되고 있습니다.

0 조회
Back to Blog

관련 글

더 보기 »

JavaScript 변수와 데이터 타입 (초보자 가이드)

변수란 무엇인가? 변수를 정보를 저장하는 상자라고 생각해 보세요. - 한 상자는 당신의 이름을 저장합니다. - 또 다른 상자는 당신의 나이를 저장합니다. - 또 다른 상자는 당신이 …인지 여부를 저장합니다.