indexOf and lastIndexOf methods | String Object In JavaScript
Vložit
- čas přidán 26. 07. 2024
- 🎁 Join my channel to get access to perks:
/ @codeexplained
🧡 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 : / code.explained.official
◾ Twitter : / code_explained
◾ Instagram : / code.explained.official
◾ GitHub : github.com/CodeExplainedRepo
💲 Suppport the Channel
Paypal : paypal.me/CodeExplained
Buy Me a Coffee: www.buymeacoffee.com/CodeExpl...
thank you very much, please continue making such videos
Bro! your effort in making this video and visualizations is A++.Thank you so much!
Thankyou so much. You have explained it very well
thank you so much for making this series, very helpful
Thank you very much. Your explanations is so precisful and understandable.
Thank you!!!
Love the way you Teach. Love from Bangladesh 🇧🇩
Glad you like it, thanks
Thanks ,IT is very helpful and superb explanation
Thank you! Great job 👏🏼
You're so welcome!
excellent
thank you so much
It's 1:41am in India 😴😴
Go get some rest bro!
Please do more, great explained....
thanks a lot, I will
THANK U GREAT MAN, You have GREAT GREAT TUTORIALS. MY WISH is that u could pick a practical e.g CRUD IN JS and explain the logic. or explain the common JS logic. Thanks again
You're welcome.
thanks for your suggestion.
So when you said CRUD do you mean any particular database?
@@CodeExplained it could use nodejs with vanilla JavaScript or just like the TODO LIST you did but you explain the logic of CREATE, READ, UPDATE and DELETE. how the logic interact with the DOM (form) and events. Thank u very much again
@@CodeExplained here a link czcams.com/video/fL9cts8ykbUo/video.htmlf example BUT YOUR EXPLANATION IS THE BEST ON JS IN CZcams; I have subscribed to many channels. ONLY YOUR CHANNEL EXPLAIN THE JS LOGIC.
if u can EXPLAIN the
1. CREATE, how the code is submitted in the forms, display list and what happens in the console.
2.READ, the LOGIC of how the code also displays items from local storage etc... no on PLAINS these METHOD: getItems(), parse() etc
THE MAJOR confusion is to understand how the DOM affects the CONSOLE
Sounds to me like empty string is philosophically like the human soul.
From StackOverflow…
The empty string is everywhere, and nowhere. It is within all strings at all times, permeating the essence of their being, yet as you seek it you shall never catch a glimpse.
Indeed, the empty string can be found between any two adjacent characters in a string as well as at the start and end. The first such instance is the very start of the string, namely position 0. All characters are separated by an empty String.
A string contains the empty string in order to be in accordance with Set Theory, according to which:
The empty set is a subset of every set including itself.
This also means that even the empty string contains the empty string.
Thanks for sharing this.