ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • JavaScript Object 예제
    Javascript 2022. 7. 18. 16:00

    EX 01. 객체

    <!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>Document</title>
    </head>
    <body>
        <script>
            let pokemon1={
                name:'피카츄',
                age:'2살',
                skill:function(){alert('백만볼트!!!')}
            }
            let pokemon2={
                name:'꼬부기',
                age:'1살',
                skill:function(){console.log('물대포!!')}
            }
            pokemon1.skill();
            document.write('첫번째 포켓몬 이름:'+pokemon1.name);
            document.write('<br>')
            document.write('첫번째 포켓몬 나이:'+pokemon1.age);
            document.write('<br>')
            document.write('두번째 포켓몬 이름:'+pokemon2.name);
            document.write('<br>')
            document.write('두번째 포켓몬 나이:'+pokemon2.age);
            document.write('<br>')
            pokemon2.skill();
        </script>
    </body>
    </html>

     

     

    'Javascript' 카테고리의 다른 글

    JavaScript JQuery 예제  (0) 2022.07.18
    JavaScript DOM 예제  (0) 2022.07.18
    JavaScript Function 예제  (0) 2022.07.18
    JavaScript Array 예제  (0) 2022.07.18
    JavaScript Basic 예제  (0) 2022.07.18

    댓글

Designed by Tistory.