var alpha = 'The brown fox was faster than the white fox.';
var beta = new String('The brown fox was faster than the white fox.');
document.writeln(alpha.indexOf('fox')+'<br>'); // Outputs 10;
document.writeln(beta.indexOf('fox')+'<br>'); // Outputs 10;
// Now we'll start looking after the first position and get the second.
document.writeln(alpha.indexOf('fox',11)+'<br>'); // Outputs 40;
document.writeln(beta.indexOf('fox',11)+'<br>'); // Outputs 40;
// Look for something which isn't there.
document.writeln(beta.indexOf('bear')+'<br>'); // Outputs -1;
kaynak: ordan burdan
Tags: java, javascript, nasıl, nedir, scripti, ScriptlerJavascript - Stringde Istenilen Kelimenin Pozisyonunu Bulmak (scripti, nasıl, nedir?) konusu
Benzer yazılar:
- Benzer yazı yok