JavaScript Array Methods Part5 - JavaScript Tutorial 102

Опубликовано: 30 Сентябрь 2024
на канале: ChidresTechTutorials
607
20

Notes for You:: JavaScript Array Methods Part5 - JavaScript Tutorial 102

JavaScript Array indexOf() and lastIndexOf() Methods.

indexOf() Method:
- returns an index of the first occurrence of given search element.

Syntax:
indexOf(searchElement:*):number
where:
searchElement: indicates element to be searched.
number: indicates index of the first occurrence of the element to be searched.


lastIndexOf() Method:
- returns an index of the last occurrence of given search element.

Syntax:
lastIndexOf(searchElement:*):number
where:
searchElement: indicates element to be searched.
number: indicates index of the last occurrence of the element to be searched.


Example Code:
var studNames = ["Ram","Ravi","Raju","Raghu","Gopla","Ravi"];

document.write(studNames); // Ram,Ravi,Raju,Raghu,Gopla,Ravi
document.write("<br/>");

document.write(studNames.indexOf("Ravi") ); // 1
document.write("<br/>");

document.write(studNames.lastIndexOf("Ravi") ); // 5
document.write("<br/>");


Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.

=========================================

Follow the link for next video:
JavaScript Get Element By Id function - JavaScript Tutorial 103
   • JavaScript getElementById() method - ...  

Follow the link for previous video:
JavaScript Tutorial 101 - concat() Method | join() Method | JavaScript Array Methods
   • JavaScript Array Methods Part4 - Java...  

=========================================

JavaScript Tutorials Playlist:-
   • JavaScript Tutorials  

=========================================
Watch My Other Useful Tutorials:-

jQuery Tutorials Playlist:-
   • jQuery Tutorials  

jQuery UI Tutorials Playlist:-
   • jQuery UI Tutorials  

Bootstrap Tutorials Playlist:-
   • Bootstrap4 Tutorials  

=========================================

HI, I am Manjunath Chidre and I'm an Indian born. I make video tutorials on Computer Science, Information Technology, Animation, VFX, Multimedia, & Gaming courses. Essentially, I set my goal to help students around the world; to learn at free of cost; through my educational YouTube channel Chidre'sTechTutorials.

=========================================

Every video on my channel is made with Love and Hard work, So don't forget to Like, Comment & Share.
Please do Subscribe, Hit the bell icon & Enjoy Learning. It's FREE.

=========================================

Subscribe to our YouTube channel:-
   / chidrestechtutorials  

Join as member of our YouTube channel:-
https://www.youtube.com/chidrestechtu...

Become our Patron:-
  / chidrestechtutorials  

Visit our Website:-
https://www.chidrestechtutorials.com

Download our Notes from Instamojo:-
https://chidrestechtutorials.myinstam...

Buy our Products on Spring:-
https://chidres-tech-tutorials.creato...

=========================================
Follow us:-

Google My Business:-
https://chidrestechtutorials.business...

Google Blog:-
http://manjunathchidre.blogspot.com

LinkedIn:-
  / chidrestechtutorials  

Facebook:-
  / chidrestechtutorials  

Twitter:-
  / manjunathchidre  

Tumblr:-
  / chidrestechtutorials  

Pinterest:-
  / chidrestechtutorials  

=========================================

Despite my inconsistent uploads; Thanks for being amazing learners and still sticking with me on YouTube.

=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial