Array indexes start at 0 and continue through length-1
. So you want
for (var i = 0; i < array.length; i++)
// ----------^----^
More Related Contents:
- Loop through an array in JavaScript
- Why is using “for…in” for array iteration a bad idea?
- What is the difference between ( for… in ) and ( for… of ) statements?
- Remove items from array with splice in for loop [duplicate]
- Check if object value exists within a Javascript array of objects and if not add a new object to array
- JavaScript Loops: for…in vs for
- Why is the loop assigning a reference of the last index element to? [duplicate]
- How do I group items in an array by date?
- JavaScript – Nuances of myArray.forEach vs for loop
- Two arrays, where items in array x can be in array y but not vice versa, test all permutations
- push() a two-dimensional array
- Javascript: hiding prototype methods in for loop?
- Sum values from an array of key-value pairs in JavaScript
- Difference between ( for… in ) and ( for… of ) statements?
- Javascript Array value [closed]
- How to remove item from array by value? [duplicate]
- Javascript call() & apply() vs bind()?
- How to detect if a variable is an array
- What is the most efficient way to reverse an array in Javascript?
- JavaScript loop variable scope
- How can I find matching values in two arrays? [duplicate]
- Sort an array with arrays in it by string
- Unpacking array into separate variables in JavaScript
- Using Array objects as key for ES6 Map
- Uncaught TypeError: Object.values is not a function JavaScript
- Multiple markers Google Map API v3 from array of addresses and avoid OVER_QUERY_LIMIT while geocoding on pageLoad
- How to display pyramid using JavaScript?
- Issue with JSON.stringify adding a extra \ and “” to my Json object
- How to access array in circular manner in JavaScript
- Getting max value(s) in JSON array