JavaScript에서 참을 확인하는 짧은 형식

변수 test가 값 true와 같은지 알고 싶다고 가정해 봅시다. 이 경우 if 구문은 다음과 같이 작성할 수 있습니다:

javascriptlet test = true;

if (test == true) {
  console.log('+++');
} else {
  console.log('---');
}

프로그래밍할 때 이러한 확인은 매우 자주 필요하므로, 더 우아한 짧은 형식이 있습니다: if (test == true) 대신에 간단히 if (test)라고 작성할 수 있습니다.

이제 우리의 코드를 짧은 형식으로 다시 작성해 보겠습니다:

javascriptlet test = true;

if (test) {
  console.log('+++');
} else {
  console.log('---');
}
Задание 1

다음 코드를 짧은 형식을 사용하여 다시 작성하세요:

javascriptlet test = true;

if (test === true) {
  console.log('+++');
} else {
  console.log('---');
}