๐ย Reference
๐ย Chapter
lastIndexOf(searchString)
lastIndexOf(searchString, position)
strย ๋ค์์๋ถํฐย (index: 0) ์ง์ ํย searchString๊ฐ ์ฒ์์ผ๋ก ๋ฐ๊ฒฌ๋๋ ์์น์ย indexย ๋ฐํํ๋ค. ๋ฐ๊ฒฌํ์ง ๋ชปํ๋ฉดย -1์ ๋ฐํํ๋ค.undefined๋ฅผ ์ ๋ฌํ๋ฉด lastIndexOf()๊ฐ ๋ฌธ์์ด "undefined"๋ฅผ ๊ฒ์ํ๊ฒ ๋๋๋ฐ, ์ด๋ ๊ฑฐ์ ์ํ๋ ๋ฐ๊ฐ ์๋๋ค.์์ 1
const paragraph = "I think Ruth's dog is cuter than your dog!";
const searchTerm = 'dog';
console.log(
`Index of the last ${searchTerm} is ${paragraph.lastIndexOf(searchTerm)}`,
);
// Expected output: "Index of the last "dog" is 38"