JavaScript 문자열 startsWith()

1 개요[ | ]

JavaScript startsWith()
자바스크립트 startsWith()
JavaScript
Copy
var str = "Hello world!";
console.log( str.startsWith("Hello") ); // true
console.log( str.startsWith("He") ); // true
console.log( str.startsWith("ll") ); // false
console.log( str.startsWith("ll", 2) ); // true
true 
true 
false 
true 
JavaScript
Copy
const str1 = 'Saturday night plans';
console.log(str1.startsWith('Sat')); // true
console.log(str1.startsWith('Sat', 3)); // false
true 
false 
JavaScript
Copy
const str = "To be, or not to be, that is the question.";
console.log(str.startsWith("To be")); // true
console.log(str.startsWith("not to be")); // false
console.log(str.startsWith("not to be", 10)); // true
true 
false 
true 

2 같이 보기[ | ]

3 참고[ | ]