김숭늉 마음대로

왕초보 자바스크립트(코딩앙마) #14 배열(array) 본문

IT/JavaScript

왕초보 자바스크립트(코딩앙마) #14 배열(array)

김숭늉이 2023. 3. 12. 19:11
728x90

1. 배열

    ㄴ 순서가 있는 리스트라고 생각하면 쉽다!

    ㄴ 배열의 고유번호를 index라고 함!

        숫자, 객체, 함수 등도 포함 될수 있음 

 

 

 

 

 

 

 

 

let days = ['mon', 'tue', 'wed'];

console.log(days.length)  /// 3출력

days[1] = '화요일'   

days.push('thur');
days.unshift('sun')

for(let index=0; index<days.length;index++) {
  console.log(days[index])   // sun, mon, tue, wed, thu 출력됨
}

 

let days = ['mon', 'tue', 'wed'];

days.push('thu');
days.unshift('sun')

for(let day of days) {   //day말고 x등 원하는 아무거나 쓰면됨!
  console.log(day)
}
728x90
반응형