Post

Web 스터디-3. 데이터 타입

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<html>
    <body>
        <h1>Datatype</h1>
        <h2>Number</h2>
        <script>
            document.write(1);
            document.write('<br>');
            document.write(1+1);
            document.write('<br>');
            document.write(1-1);
            document.write('<br>');
            document.write(2*2);
            document.write('<br>');
            document.write(4/2);
            document.write('<br>');
            document.write(Math.PI); //math 에 내장된 원주율값
            document.write('<br>');
            document.write(Math.floor(1.9)); //math 내장 floor(내림)값 가져오기
            document.write('<br>');
        </script>
        <h2>문자열 (string)</h2>
        <script>
            document.write('hello');
            document.write('<br>');
            document.write("hello");
            document.write('<br>');
            document.write('hello \
            world'); // \쓰면 코드 내려서 쓰겠다는 의미(실제 결과물에는 반영 안됨)
            document.write('<br>');
            document.write('hello world'.length); // 글자수 값 가져와서 쓰기
            document.write('<br>');
            document.write('hell world'.replace('hell', 'hello')); // 문장 속 특정단어 바꾸기
            document.write('hell world'.replaceAll('hell', 'hello')); // 문장 속 특정단어 모두 바꾸기
            document.write('<br>');
            document.write('<br>');
            document.write('hello' + 'world'); // 결합연산자
            
        </script>
    </body>
</html>

ㅡㅡㅡㅡㅡㅡㅡㅡㅡ 적용예 ㅡㅡㅡㅡㅡㅡㅡㅡㅡ

Datatype

Number

문자열 (string)

This post is licensed under CC BY 4.0 by the author.