split, splice, slice
모든 js 메소드는 mdn 공식문서를 참고하자 !!
정말 비슷하게 생겨서 자꾸 헷갈리게 하는 친구들
split
String.prototype.split()
The
split()
method divides aString
into an ordered list of substrings, puts these substrings into an array, andreturns the array
. The division is done by searching for a pattern; where the pattern is provided as thefirst parameter
in the method's call.
> split의 syntax
split()
split(separator)
split(separator, limit)
splice
Array.prototype.splice()
The
splice()
method changes the contents of an array byremoving
orreplacing
existing elements and/oradding
new elements in place. To access part of an array without modifying it, see slice().
> splice의 syntax
splice(start)
splice(start, deleteCount)
splice(start, deleteCount, item1)
splice(start, deleteCount, item1, item2, itemN)
slice
slice -> Array 일때
Array.prototype.slice()
The
slice()
method returns a shallow copy of a portion of an array into anew array
object selected from start to end (end not included) where start and end represent the index of items in that array. The original array willnot be modified
.
> slice의 syntax
slice()
slice(start)
slice(start, end)
slice -> String 일때
String.prototype.slice()
The
slice()
method extracts a section of astring
and returns it asa new string
,without modifying
the original string.
> slice의 syntax
slice(beginIndex)
slice(beginIndex, endIndex)
Author And Source
이 문제에 관하여(split, splice, slice), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@howyoujini/split-splice-slice저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)