Programing/Spring , Springboot , JPA

자바스크립트(JavaScript) - 객체

하얀배터리 2020. 4. 10. 01:12
728x90

 

 

 

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
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>객체</title>
    <script>
        function fCheck(){
            var tv = new Object();   //  객체 끝   객체변수 tv 
            tv.color = "검정";
            tv.price =100000;
            tv.office ="삼성";
            document.write("색상 =" +tv.color+"<br/>");
            document.write("가격 =" +tv.price+"<br/>");
            document.write("회사 =" +tv.office+"<br/>");
            document.write("부가세 =" +(tv.price*0.1+"<br/>");
 
            tv.infor = function(){  //익명함수 [함수이름이 없는함수 ]   [익명함수의 내용을  infor가 가지고 있다. ]
                document.write("2 색상 =" +tv.color+"<br/>");
                document.write("2 가격 =" +tv.price+"<br/>");
                document.write("2 회사 =" +tv.office+"<br/>");
                document.write("2 부가세 ="+(tv.price*0.1+"<br/>");
            }
            tv.infor();
        }
    </script>
</head>
<body>
    <h2>객체만들기</h2>
    <p><input type="button" value="객체만들기" onclick="fCheck()" /></p>  <!--함수는 무조건 ()-->
</body>
</html>
 
 

 

 


결과 화면 

 

버튼 클릭시 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90