Русские видео

Сейчас в тренде

Иностранные видео




Если кнопки скачивания не загрузились НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу страницы.
Спасибо за использование сервиса savevideohd.ru



How to find length of array in javascript

1. students.length • students.length gives you the total number of elements in the students array. • It counts all items in the array starting from 1. • Example: If the array has 3 students, students.length will be 3. let students = [ { name: "Alice", age: 20 }, { name: "Bob", age: 22 }, { name: "Charlie", age: 19 } ]; console.log(students.length); // Output: 3 students.length - 1 • students.length - 1 gives you the index of the last element in the array. • Since JavaScript arrays are zero-indexed, the last element is always at the index length - 1. • Example: If the array has 3 students, the last student is at index 3 - 1 = 2. • When you want to get the last item in the array, you need to use students.length - 1 to access the correct index. let students = [ { name: "Alice", age: 20 }, { name: "Bob", age: 22 }, { name: "Charlie", age: 19 } ]; console.log(students.length - 1); // Output: 2 (the index of the last student)

Comments