JavaScript indexOf() Method
Want to understand Properly Plz see the video carefully on YouTube channel name is Adisma
The indexOf()
method returns the position of the first occurrence of a value in a string.
The indexOf()
method returns -1 if the value is not found.
The indexOf()
method is case sensitive.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">a
<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 = indexOf() Method</h1>
<script>
const myFriends = ["seema", "Seema Sharma", "Adisma", "seema", "Aditya"];
console.log( "Index Number =" + myFriends.indexOf("Adisma", 2));
// const searchValue = myFriends.indexOf("Seema Sharma")
</script>
</body>
</html>
Comments
Post a Comment