JS- 배열

Jeongwon·2022년 1월 13일
0

Java Script

목록 보기
11/14

배열

var friends = ["mj", "sj", "wj"];

접근

friends[0]

추가

friends.push('ny');

길이

friends.length

👉코드

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1>Array</h1>
    <h2>Syntax</h2>
    <script>
      var friends = ["mj", "sj", "wj"];
    </script>
    <h2>get</h2>
    <script>
      document.write(friends[0]);
      document.write(friends[1]);
      document.write(friends[2]);
    </script>

    <h2>add</h2>
    <script>
      friends.push('ny');
    </script>
    <h2>count</h2>
    <script>
      document.write(friends.length);
    </script>
  </body>
</html>
profile
(❁´◡`❁)

0개의 댓글