Forgot username/password? Don't have an account?
Login with Facebook
Home » Courses » Arrays » indexOf vs. lastIndexOf
Subscribe for updates.
* New to us? log in with Facebook and get a free day pass


  1. Overview (02:27)
  2. new Array(); (03:37)
  3. Array vs. Object (03:18)
  4. Setting a size to our Array (03:28)
  5. Starting Up With Content (02:18)
  6. Working With Arrays (08:36)
  7. Editing Array Data (07:07)
  8. push (03:48)
  9. unshift (03:11)
  10. Intergrating Into Our Mini App (04:54)
  11. pop and shift (05:51)
  12. indexOf vs. lastIndexOf (09:29)
  13. splice (09:48)
  14. reverse (01:47)
  15. [] (01:47)
  16. Summary (01:30)

indexOf vs. lastIndexOf

We know how to grab the last thing and the first thing but how do we find things in the middle. this is exactly where indexOf and lastIndexOf are very handy.

Question: What is the difference between indexOf and lastIndexOf?

It's very simple: an array is like a line. imagine that there are 20 people standing in a line every one has there own name. when we ask for indexOf we start looking for "ben" from the start of the line starting at index 0 and going on until we find "ben" while when we use lastIndexOf we start from the end of the line. what's the catch you might be thinking. the best way to answer that is through a question "what if there are more then one 'ben' in the line? as it returns the index of the first thing it hits different values would return depending on our choice to start from the end or the start looking for that match. there are a few more layers to this and that we will explore more in the video.
Got A Question?

'I love being Prime'

Have a question but don't want to ask it publicly? If you are a prime member just ask right here and we will get back to you within 48 hours. Not prime yet? no worries you can ask publicly below.

Act now while we have available seating

Our on line school is private, affordable and interactive with trainer support.
Act now save your seat before someone else takes yours.
Act now