forEach

» JavaScript

forEach란?

for문과 마찬가지로 반복적인 기능을 수행할 때 쓰임

  • 메소드
      const arr = [0,1,2,3,4,5,6,7,8,9,10];
    
      // 함수
      arr.forEach(function(element) {
          console.log(element); // 0 1 2 3 4 5 6 7 8 9 10
      });
    
      // 화살표 함수
      arr.forEach(element => console.log(element)); // 0 1 2 3 4 5 6 7 8 9 10
    

출처: 네이버블로그