๐ Reference
๐ย Chapter
true, ์๋๋ฉด false ๋ฐํtest()ย ๋ฉ์๋๋ ์ ๊ท ํํ์์ย lastIndex๋ฅผ ์
๋ฐ์ดํธํ๋ค. (RegExp.prototype.exec()๋ย lastIndexย ์์ฑ์ ์
๋ฐ์ดํธํ๋ค.)test(str)์ ๋ ํธ์ถํ๋ฉดย strย ๊ฒ์์ย lastIndex๋ถํฐ ๊ณ์ ์งํํ๋ค.ย lastIndexย ์์ฑ์ ๋งค ๋ฒย test()๊ฐย true๋ฅผ ๋ฐํํ ๋๋ง๋ค ์ฆ๊ฐํ๊ฒ ๋๋ค.test()๊ฐย true๋ฅผ ๋ฐํํ๊ธฐ๋ง ํ๋ฉดย lastIndex๋ ์ด๊ธฐํ๋์ง ์๋๋ค.test()๊ฐย false๋ฅผ ๋ฐํํ ๋ย lastIndexย ์์ฑ์ดย 0์ผ๋ก ์ด๊ธฐํ๋๋ค.regexObj.test(str);
(์ ๊ทํํ์).test("๋ฌธ์์ด");
str
strย ์ค ์ ๊ท ํํ์์ด ์ผ์นํ๋ ๋ถ๋ถ์ด ์์ผ๋ฉดย true, ์๋๋ฉด,ย false.