모든 js 메소드는 mdn 공식문서를 참고하자 !!
정말 비슷하게 생겨서 자꾸 헷갈리게 하는 친구들
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()
split(separator)
split(separator, limit)
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(start)
splice(start, deleteCount)
splice(start, deleteCount, item1)
splice(start, deleteCount, item1, item2, itemN)
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()
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(beginIndex)
slice(beginIndex, endIndex)