String Object In JavaScript indexOf and lastIndexOf Methods

🎁 Join my channel to get access to perks:

🧡 Hello All JavaScript Lovers Outhere!

Today you’re going to learn about the String Object In JavaScript.

This tutorial is a series of videos, in each video we will discuss a method (or more) of the String Object in JavaScript.

In today’s video, you’re going to learn about two string methods, indexOf and lastIndexOf, and know the difference between them.

indexOf is used to get the index of the first occurrence of a searched string in a given string, and lastIndexOf is used to get the index of the last occurrence of the searched string.

Example :
const str = “The code is not working, the code is buggy.”;
console.log(str.indexOf(“code”)); // logs : 4
console.log(str.lastIndexOf(“code”)); // logs : 30

Both indexOf and lastIndexOf take in a second parameter called position, and it’s simply the index you want to start the search for your “search string”.

🌍 Social Media Links.
◾ Facebook :
◾ Twitter :
◾ Instagram :
◾ GitHub :

💲 Suppport the Channel
Paypal :
Buy Me a Coffee:

How to Find the Best JavaScript For Beginner Books

JavaScript for beginner|JavaScript for beginner

How to Find the Best JavaScript For Beginner Books

There are many ways to learn JavaScript, and you can start by reading a book that is tailored to beginners. You may not be able to understand some aspects of the language if you read a book that is meant for more experienced JavaScript users. Therefore, if you are a beginner and want to learn this language, you should find the best JavaScript for beginners book. The book should be written in a way that is easy to understand for a beginner.

You May Also Like