Клиентский JavaScript. Справочник

         

и lastIndexOf используются для локализации


Здесь методы indexOf и lastIndexOf используются для локализации значений в строке "Brave new world."
var anyString="Brave new world"// Выводит 8
document.write("<P>The index of the first w from the beginning is " +
   anyString.indexOf("w"))
// Выводит 10
document.write("<P>The index of the first w from the end is " +
   anyString.lastIndexOf("w"))
// Выводит 6
document.write("<P>The index of 'new' from the beginning is " +
   anyString.indexOf("new"))
// Выводит 6
document.write("<P>The index of 'new' from the end is " +
   anyString.lastIndexOf("new"))

Содержание раздела