Vérifie si la chaîne du premier argument se termine par une chaîne spécifique (chaîne du deuxième argument). Si la chaîne est introuvable, renvoie -1.
Chaîne
indexOf(<parameters>)
Paramètre | Type |
---|---|
string | Chaîne |
valeur spécifiée | Chaîne |
indexOf(<string>,<string>)
Renvoie un entier.
indexOf("Hello", "l")
Renvoie 2.
Explication :
Dans « Hello », la première occurrence de « l » est en position 2.