본문 바로가기
웹코딩 배우기/· JavaScript

자바스크립트 - type 정의

by 닐기 2023. 2. 14.

See the Pen typeof by nilgi (@nilgi) on CodePen.

▶ 값을 포함할 수 있는 5가지 데이터 유형 
• string
• number
• boolean
• object
• function

 6가지 유형의 객체
• Objecr
• Date
• Array
• String
• Number
• Boolean

 값을 포함할 수 없는 2가지 데이터 유형
• null
• undefined



    typeof "hw" + "<br/>" +      // string
    typeof 2424 + "<br/>" +      // number
    typeof NaN + "<br/>" +      // number
    typeof false + "<br/>" +      // boolean
    typeof [4,6,11] + "<br/>" +      // object
    typeof {name:'hw', w:68} + "<br/>" +      // object
    typeof new Date() + "<br/>" +      // object
    typeof function () {} + "<br/>" +      // function
    typeof myCom + "<br/>" +      // undefined
    typeof null;      // object