... (three dots)

차노·2023년 8월 18일
0

JS

목록 보기
66/96

정의

In JavaScript, the '...' (three dots) syntax is known as the spread/res operator, and its meaning depends on how it's used different context.
자바스크립트에서, 쓰리 다츠는 어떻게 사용되느냐에 따라 스프레드와 나머지 파라미터로 나눠진다._

  1. Spread Operator: When used in the context of spreading, the '...' syntax allows you to spread the elements of an iterable (like an array or a string) into individual elements

    스프레딩의 맥락으로 사용될 때, '...' 신텍스는 각 요소로 돌아가는 요소를 퍼지게 할 때 사용한다.(배열이나 문자열 처럼)

It is used to expand an iterable into its individual elements.

각 요소에 자동화를 확장할 때 사용된다.

복사의 개념으로 이해하면 조금 쉽다. ...array라는 표현으로 array에 있는 배열 [1, 2, 3]을 갖고와 newArray에 붙였다.

  1. Rest Parameter: In function parameter lists, the '...' syntax is used as a rest parameter to represent an indefinite number of arguments as an array.

    함수 파라미터 리스트에서, '...' 신텍스는 배열로 인자의 정의되지 않은 수를 표현하도록 나마지 파라미터로서 사용된다.

In this example, the rest parameter '...numbers' collects all arguments passed to the sum function as an array.

위 예에서, 레스트 파라미터 ...numbers는 배열로 썸 함수에 모든 넘겨진 인자들을 취합한다.

  1. Destructing:

0개의 댓글