본문 바로가기
프로그래밍/Java Script

Java Script - 불리언 메소드 boolean method

by 3.14pie 2022. 12. 5.

Boolean - 참과 거짓을 나타낸다.

        let a = true;
        let b = new Boolean(true);
        let c = 0;

        console.log(typeof a);
        console.log(typeof b);
        console.log(Boolean(c));

a는 boolearn 타입이고, b는 object 타입이다.

선언하는 방식에 따라 타입이 바뀐다. (String도 new String으로 선언하면 object 타입으로 생성된다.)

boolean은 1을 제외한 것은 모두 false로 출력한다.