[JavaScript] Boolean

Cadet_42·2021년 7월 28일
0

JavaScript

목록 보기
5/8
post-thumbnail

What is a Boolean?

  • Boolean is a type of data that can have two different values: true or false.

  • Do you like cat? YES

  • Do you like beer? NO

Comparison operators

Logical operators : AND, OR, and NOT

Truthy and Falsy

JavaScript, and many other languages, support boolean data types that could be true or false. In addition to that, everything in JavaScript has an implicit boolean value that can be truthy or falsy. When you say that a value is truthy in JavaScript, it doesn’t mean that the value is true. Instead, it means that the value will result as true when evaluated in a boolean context.
Correspondingly, when you say a value is falsy in JavaScript, it means the value translates to false when evaluated in a Boolean context.

3 different data types in JS

  • undefined is a value, automatically set by JS, to a variable that was declared, but not initialized with a value.
  • null is a type of data in JS that points, generally intentional, to a non-existing value.
  • NaN or Not a Number is commonly the result of trying to apply Number methods to data types that are not numbers.
profile
안녕하세요! 개발공부를 하고 있습니다. 감사히 배우겠습니다. ;)

0개의 댓글