[JS 문법 종합반] 1주차
for문
# for문 기본골격
for(초기값; 조건식; 증감식) {}
# 예시
for(let i = 0; i<10; i++) {
console.log(i)
}
// i 변수는 0부터 시작할거야
// i 변수는 10이 되기 전까지 계속 돌거야
// i 변수는 한 사이클{} 을 돌고나면 1을 더할거야
// 출력 : 0 1 2 3 4 5 6 7 8 9
객체와 배열
- 객체
# 객체(Object)
key-value pair
# 객체 생성
let person = {
name : '홍길동',
age : 30,
gender : '남자'
};
# 객체 접근 방법
cosole.log(person.name); // '홍길동'
cosole.log(person.age); // 30
cosole.log(person.gender); // '남자'
- 배열
# 배열(Array)
배열 : 나열한다
인덱스(순서)가 있음
# 배열 생성
let fruit = ['사과', '바나나', '오렌지']
0 1 2
# 배열 접근 방법
console.log(fruit[0]) // 사과
console.log(fruit[1]) // 바나나
console.log(fruit[2]) // 오렌지
'⛵ 항해99 > TIL · WIL ✏️' 카테고리의 다른 글
[TIL] 2023.08.18 - 프로그래머스 / forEach() / parseInt() / split() (0) | 2023.08.18 |
---|---|
[TIL] 2023.08.17 - 프로그래머스 (0) | 2023.08.17 |
[TIL] 2023.08.16 - 숫자 야구 프로그램 / Math.random() /문자열 변경(숫자 + '') / 문자열 인덱스 접근 / includes() (0) | 2023.08.16 |
[TIL] 2023.08.15 - 프로그래머스 / Map과 Set (0) | 2023.08.15 |
[WIL] 개강 준비 주차(스타터 노트) (0) | 2023.08.13 |