String Object In JavaScript indexOf and lastIndexOf Methods

🎁 Join my channel to get access to perks:
https://www.youtube.com/channel/UC8n8ftV94ZU_DJLOLtrpORA/join

🧡 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 : https://www.facebook.com/Code.Explained.Official
◾ Twitter : https://twitter.com/code_explained
◾ Instagram : https://www.instagram.com/Code.Explained.Official/
◾ GitHub : https://github.com/CodeExplainedRepo

💲 Suppport the Channel
Paypal : https://paypal.me/CodeExplained
Buy Me a Coffee: https://www.buymeacoffee.com/CodeExplained

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