1. 문자 타입 

문자 타입은 " " 따옴표로 묶어줍니다.

 var stringType = "문자타입 입니다.";
 console.log(stringType);
 var myString = "문자 더하기"+ "문자";
 console.log(myString);

 

2. 숫자타입

 

Integer >   32-bit number ( -2,147,483,648 ~ 2,147,483,647)

Long >  64-bit number (-9,223,372,036,854,775,808  ~ 9,223,372,036,854,775,807)

Float >   3.4E+/-38(7개의 자릿수)

Double >  1.7E+/-308(15개의 자릿수)

var numberType = 5;
console.log(numberType * numberType);

var integerType = 10;
var longType1 = 9223372036854775808;
var longType2 = 9223372036854775807;
var floatType = 3.5;
var doubleType = 9310141419482.22;

 

3. 기타 

var booleanType = true;
var notAnumberType = NaN;
var undefinedType;
var nullType = null;

 

전체 코드

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>
        JavaScript Variables
    </h1>
</body>
</html>
<script>
//문자타입
    var stringType = "문자타입 입니다.";
    console.log(stringType);
    var myString = "문자 더하기"+ "문자";
    console.log(myString);
//숫자타입
    var numberType = 5;
    console.log(numberType * numberType);

    var integerType = 10;
    var longType1 = 9223372036854775808;
    var longType2 = 9223372036854775807;
    var floatType = 3.5;
    var doubleType = 9310141419482.22;
    var booleanType = true;
    var notAnumberType = NaN;
    var undefinedType;
    var nullType = null;


    console.log(integerType);
    console.log(longType1);
    console.log(longType2);
    console.log(floatType);
    console.log(doubleType);
    console.log(booleanType);
    console.log(notAnumberType);
    console.log(definedType);
    console.log(nullType);

    


</script>

 

결과

 

+ Recent posts