for (반복문)

김정민·2021년 12월 6일
0

forEach 문

const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element+'!!'));

// expected output: "a!!"
// expected output: "b!!"
// expected output: "c!!"

반환값이 없다

for of 문

for (let value of array) {
  console.log(value);
}
/*
10
20
30
40
50
*/

값을 출력

for in 문

for (let value in array) {
  console.log(value)
}
/*
0
1
2
3
4
*/

for (let value in array) {
  consloe.log(array[value])
}
/*
10
20
30
40
50
*/

인덱스 값 출력

0개의 댓글

관련 채용 정보