en.javascript.info/1-js/4-data-structures/7-array/1-get-last-in-array/solution.md
2015-01-11 01:54:57 +03:00

16 lines
577 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Последний элемент имеет индекс на `1` меньший, чем длина массива.
Например:
```js
var fruits = ["Яблоко", "Груша", "Слива"];
```
Длина массива этого массива `fruits.length` равна `3`. Здесь "Яблоко" имеет индекс `0`, "Груша" -- индекс `1`, "Слива" -- индекс `2`.
То есть, для массива длины `goods`:
```js
var lastItem = goods[goods.length-1]; // получить последний элемент
```