Javascript
[JS/ES6] 추가된 String의 메서드들
자기개발자 유자
2019. 2. 2. 17:53
728x90
반응형
ES6에서 추가된 String의 메서드들
String.startsWith(matchString) |
matchString이 String의 앞부터 일치하는지 확인 (true/false) |
String.endsWith(matchString) |
matchString이 String의 뒤부터 일치하는지 확인 (true/false) |
String.includes(matchString) |
matchString이 String에 포함되어 있는지 확인(true/false) |
예시
let str = "hello world ~!~!";
str.startsWith("hello"); //true
str.endsWith("~!~!"); //true
str.startsWith("h ello"); //false
str.endsWith("~! ~!"); //false
str.includes("~!"); //true
728x90
반응형