string.includes
includes() ๋ฉ์๋๋ ํ๋์ ๋ฌธ์์ด์ด ๋ค๋ฅธ ๋ฌธ์์ด์ ํฌํจ๋์ด ์๋์ง์ ํ๋ณํ๊ณ ์ด๋ฅผ true ํน์ false ๋ก ๋ฐํํ๋ค.
const sentence = '๊ณ ์์ด๊ฐ ์งฑ์ด๋ท!';
const word = '๊ณ ์์ด';
`์ด ๋ฌธ์ฅ์ ${word}๊ฐ ํฌํจ๋์ด ${sentence.includes(word) ? '์๋ค' : '์์ง ์๋ค'}`; // "์ด ๋ฌธ์ฅ์ ๊ณ ์์ด๊ฐ ํฌํจ๋์ด ์๋ค"Syntax
str.includes(searchString[, position])Parameters
searchString
str ์์ ์ฐพ์ ๋ฌธ์์ด
position (Optional)
๋ฌธ์์ด ์์ ์ฐพ๊ธฐ ์์ํ ์์น (๊ธฐ๋ณธ๊ฐ์ 0์ด๋ค)
Return value
์ฃผ์ด์ง ๋ฌธ์์ด ๋ด์์ ๊ฒ์ ๋ฌธ์๊ฐ ์กด์ฌํ๋ฉด true ๊ทธ๋ ์ง ์๋ค๋ฉด false
Description
Case-sensitivity
๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ค.
Examples
Polyfill
IE๋ ์ง์๋์ง ์๋๋ค.
ECMAScript 2015 ์คํ์ ์ถ๊ฐ๋จ
Last updated
Was this helpful?