JavaScript
-
javascript Arr(어레이)관련 함수 들 (splice shift,pop,unshift,push, indexOf, lastIndexOf, includes)JavaScript 2021. 2. 13. 20:35
javascript array에서 사용 되는 함수들 let num = ["one", "two", "three"] 1. splice(startIndex, delectCount) let num = ["one", "two", "three"] num.splice(1,1) 위와 같이 선언하면 "one"이 제거 된다. 또 다른 사용법으로 값의 대체도 가능하다. splice(startIndex, delectCount, item) num.splice(1,1,"four", "five") 위와 같이 선언하면 "1"번째 인덱스인 "two"가 사라지고 "four", "five"가 들어온다. num.splice(1,0, "four", "five") 조금 더 응용하자면 제거하지 않고 값을 넣는것만도 가능하다. 2. shift()..