JavaScript lastIndexOf() method
Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma
Definition and Usage
The lastIndexOf()
method returns the index (position) of the last occurrence of a specified value in a string.
The lastIndexOf()
method searches the string from the end to the beginning.
The lastIndexOf()
method returns -1 if the value is not found.
The lastIndexOf()
method is case sensitive.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Searching In An Array = lastIndexOf () Method</h1>
<script>
const myFriends = ["seema", "Seema Sharma", "Adisma", "seema", "Aditya"];
const indexNumber = myFriends.lastIndexOf("SS",2);
console.log("Index NUmber = " +indexNumber);
</script>
</body>
</html>
Comments
Post a Comment