Skip to content

forEach - for in #42

Closed
Closed
@MoSonLee

Description

@MoSonLee
  • for in
    • 각각의 element들을 순차적으로 호출함
    • break, continue 사용 가능
    • return을 사용하면 반복문이 종료됨

  • forEach
    • 반복 실행하려는 코드를 Parameter로 받고 저장된 요소는 클로저 상수로 전달됨
    • 전달한 클로저를 요소의 갯수만큼 실행됨
    • for in과 동일하게 각각의 Element들을 호출함
    • for in과는 다르게 break, continue를 사용할 수 없음
    • return이 for문과는 다르게 내가 전달한 클로저를 종료하는 것임
    • 한마디로 반복횟수에 영향을 주지 않고 모두 실행됨

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions