JS/JS 수업분

[JS] day07_datatype

congs 2023. 4. 17. 22:59
 
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>dataType</title>
</head>
<body>
    <ul>
        <li>숫자</li>
        <li>문자</li>
        <li>블리언</li>
        <li>객체</li>
        <li>배열</li>
        <li>알수없는값</li>
        <li>미정된 값</li>
        <li>데이터 타입 확인 명령어</li>
    </ul>
   
    <script>
        let num = 1234;
        let str = "문자";
        let bool = true;
        let obj1 = new Object(); // new Object : 자바스크립트에서 제공하는 내장객체
        let obj2 = { };
        let arr = [1, 2, 3];
        let arr2 = new Array(); // 자바스크립트에서 제공하는 Array 객체
        let undi = undefined;
        let nul = null;
        let nudi2;

        console.log(`num: ${typeof num}`);
        console.log(`nan: ${typeof NaN}`);
        console.log(`str: ${typeof str}`);
        console.log(`bool: ${typeof bool}`);
        console.log(`obj1: ${typeof obj1}`);
        console.log(`obj2: ${typeof obj2}`);
        console.log(`arr: ${typeof arr}`);
        console.log(`arr2: ${typeof arr2}`);
        console.log(`undi: ${typeof undi}`);
        console.log(`nul: ${typeof nul}`);
        console.log(`undi2: ${typeof undi2}`);


    </script>

    <h1>변수의 관리</h1>
    <ol>
        <li>기본지료형</li>
        <li>참조지료형</li>
    </ol>

    <script>
        // == 같다, != 같지않다
        // == 값만 비교, === 자료형(타입)까지 비교
        let num1 = 10;
        let num2 = '10';

        console.log('num1 == num2', num1 == num2);
        console.log('num1 === num2', num1 === num2);
       
    </script>
</body>
</html>
 
 

'JS > JS 수업분' 카테고리의 다른 글

[JS] day07_event (버튼 클릭 이벤트)  (0) 2023.04.17
[JS] day07_Object  (0) 2023.04.17
[JS] day07_function  (0) 2023.04.17
[JS] day07_let  (0) 2023.04.17
[JS] 정규표현식 Regular Expression  (0) 2023.04.17