includes

요약
해당 문자열이 포함되어 있는지 판별 - 대소문자 구분함
Tags
테스트
포함여부
bool
str.includes(searchString[, position])

인자

searchString
이 문자열에서 찾을 다른 문자열.
position Optional
searchString을 찾기 시작할 위치. 기본값 0.
 
var str = 'To be, or not to be, that is the question.'; console.log(str.includes('To be')); // true console.log(str.includes('question')); // true console.log(str.includes('nonexistent')); // false console.log(str.includes('To be', 1)); // false // 1번째 인덱스부터 찾기 시작하면 "To be" 문자열이 없음. console.log(str.includes('TO BE')); // false

대소문자 구분함

'Blue Whale'.includes('Blue'); // returns true 'Blue Whale'.includes('blue'); // returns false