# 03. ES2015 String 새로운 메소드

🤗 ES6에 새로 나온 String 메소드에 대해서 살펴 보겠다

# ✨ startsWith

특정 String으로 시작하는지 확인하는 메소드

let str = "hello world ! ^^ -";
let matchStr = "hello";
console.log("startWith " + matchStr, str.startsWith(matchStr));

# 🔎 console


"startWith hello"
true 

# ✨ endsWith

특정 String으로 끝나는지 확인하는 메소드

let str = "hello world ! ^^ -";
let matchStr2 = "^^ ~";
let matchStr3 = "^^ -";
console.log("endsWith " + matchStr2, str.endsWith(matchStr2));
console.log("endsWith " + matchStr3, str.endsWith(matchStr3));

# 🔎 console


"endsWith ^^ ~"
false
"endsWith ^^ -"
true

# ✨ includes

특정 String을 포함하는지 확인하는 메소드

let str = "hello world ! ^^ -";
let matchStr4 = "world";
console.log("includes " + matchStr4, str.includes(matchStr4));

# 🔎 console


"includes world"
true

# Reference


https://www.inflearn.com/course/es6-강좌-자바스크립트/dashboard (opens new window)

https://jsbin.com/ (opens new window)

Last Updated: 3/8/2024, 5:46:31 AM