본문 바로가기

개발하자/자바스크립트

배열의 키를 이용해서 값 뽑아내기

<html>
 <head>
 <style type="text/css">
 </style>
 <script>
 </script>
 </head>
 <body>
 <script>
 var obj={
 a:{b:100,c:function(){return 200;}},
 d:[400,500,600]
 };

 document.write(obj.a.b+"<br>");
 document.write(obj.a.c()+"<br>");
 document.write(obj.d[0]+"<br>");
 document.write(obj.d[1]+"<br>");
 document.write(obj.d[2]);
 </script>
 </body>
</html>