JavaScript
배열 만들고 가져오기 기초
땀모
2019. 5. 22. 04:29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <!DOCTYPE html> <html> <head> <title>Array</title> </head> <body> <h1>Array</h1> <h2>Syntax</h2> <script> var coworkers = ["딸기", "바나나"]; </script> <h2>get</h2> <script> document.write(coworkers[0]); </script> </body> </html> | cs |
수량세기, 배열추가(push)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <h1>Array</h1> <h2>Syntax</h2> <script> var coworkers = ["딸기", "바나나"]; </script> <h2>Get</h2> <script> document.write(coworkers[0]); document.write('<br>'); document.write(coworkers[1]); </script> <h2>add</h2> <script> coworkers.push("우유"); coworkers.push("빵"); </script> <h2>Count</h2> <script> document.write(coworkers.length); </script> | cs |