itsme

모각코 5일차 - 한 입 웹개발(JS) 8월 과정 본문

대외활동/모각코 - 온라인 대외활동

모각코 5일차 - 한 입 웹개발(JS) 8월 과정

itssmeee 2021. 8. 14. 17:59
반응형

이번에는 타입 및 변수에 대해서 알아봤다.

 

javascript에서는 5가지 타입이 있다.

1. 숫자(Number)

2. 문자열 (String)

3. 불리언 (Boolean)

4. null과 undefined

5. 객체 (Object)

 

c언어나, java나 파이썬에서는 int, String 등.. 타입을 이용하여 변수를 선언한다면 javascript에서는 var라는 키워드를 통해서 변수를 사용한다.

 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>5days</title>
</head>
<body>
  <script>
    var num = 0;
    var str = "string";
    var boolean = true;
    var obj = {};
    var undefind = undefind;

    console.log(typeof num);
    console.log(typeof str);
    console.log(typeof boolean);
    console.log(typeof obj);
    console.log(typeof undefind);
  </script>
</body>
</html>