String.prototype.slice()

김혁중·2022년 3월 3일
0

JavaScript

목록 보기
7/23

String.prototype.slice()

양수

const str = 'ABCDE'
str.slice(0) // 'ABCDE'
str.slice(1) // 'BCDE'
str.slice(0, 1) // 'A'

음수

const str = 'ABCDE'
str.slice(-2) // 'DE'
str.slice(0, -1) // 'ABCD'
str.slice(1, -1) // 'BCD'
profile
Digital Artist가 되고 싶은 초보 개발자

0개의 댓글