Javascript

[ES6] New string method

yemsu 2020. 3. 26. 10:53

.startsWith()

String.prototype.startsWith(searchString, position = 0)

Returns true if the receiver starts with searchString; the position lets you specify where the string to be checked starts.

 

.endsWith()

String.prototype.endsWith(searchString, endPosition = searchString.length)

Returns true if the receiver starts with searchString; the position lets you specify where the string to be checked starts.

 

.includes()

String.prototype.includes(searchString, position = 0)

Returns true if the receiver contains searchString; position lets you specify where the string to be searched starts.

 

.repeat()

String.prototype.repeat(count)

Returns the receiver, concatenated count times.

 

 

참고

https://www.inflearn.com/course/es6-%EA%B0%95%EC%A2%8C-%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8/lecture/6980)

https://exploringjs.com/es6/ch_strings.html