26 lines
981 B
Markdown
26 lines
981 B
Markdown
---
|
||
title: Array Length
|
||
localeTitle: Длина массива
|
||
---
|
||
## Длина массива
|
||
|
||
`length` - свойство массивов в JavaScript, которое возвращает или задает количество элементов в заданном массиве.
|
||
|
||
Свойство `length` массива может быть возвращено так же.
|
||
|
||
```js
|
||
let desserts = ["Cake", "Pie", "Brownies"];
|
||
console.log(desserts.length); // 3
|
||
```
|
||
|
||
Оператор присваивания в сочетании с свойством `length` может использоваться для установки количества элементов в массиве, подобном этому.
|
||
|
||
```js
|
||
let cars = ["Saab", "BMW", "Volvo"];
|
||
cars.length = 2;
|
||
console.log(cars.length); // 2
|
||
```
|
||
|
||
#### Дополнительная информация:
|
||
|
||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Array/length |