slice()

차노·2023년 8월 15일
0

JS

목록 보기
44/96

In programming, 'slice()' is a method or function available in various programming languages, including javaScript.

자바스크립트를 포함하여 다양한 프로그래밍 언어에서 사용할 수 있는 메소드이자 함수이다.

It is used to extract a portion of an array or a string wihtout modifying the original array or string.

기존의 배열 또는 스트링을 바꾸지 않고 부분을 추출하는 데 사용한다.

The 'slice' method returns a new array or string containing the selected elements or characters.

slice 메소드는 선택된 요소 또는 문자를 포함하여 새로운 형태의 배열 또는 스트링을 반환한다.

In this example, 'slice(1, 4)' extracts elements starting from index 1 (inclusive) up to index 4 (exclusive) from the original array.

위 예에서, 슬라이스(1, 4)는 기존 배열에서 인덱스 1을 포함하는 것부터 인덱스 4를 제외한 새로운 배열을 만들어냈다.

In this example, 'slice(7, 12)' extract characters from index 7(inclusive) up to index 12 (exclusive) from the original string. The resulting 'newString' will contain the charcters 'world'.

The 'slice()' method can take two arguments.

  • start(inclusive)
  • end(exclusive)

If the 'end' argument is omitted, the 'slice()' method will extract elements from the 'start' index to the end of the array or string.

It's important to note that the slice() method doesn't modify the original array or string.

I brought it back from chat Gpt.

0개의 댓글