Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

добавила более подробное описание splice/delete #6

Merged
merged 1 commit into from Oct 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Expand Up @@ -215,12 +215,20 @@ a.length; // 11
### Удаление

* delete
* splice
После удаления в массиве остается "дыра"
```javascript
массив[1].delete // удалит элемент с индексом 2 (не рекомендован к использованию так как по сути после удаления оставляет undefined)
let arr = [1, 2, 3];
delete arr[1] // удалит элемент с индексом 1
arr // [1, empty, 3]
arr[1] // undefined
```

* splice
Ключевое отличие от `delete` в том, что в итоговом массиве не останется "дыр"
```javascript
массив.splice(3, 1); // откуда начать, сколько удалить
let arr = [1, 2, 3];
arr[1].splice(1, 1) // удалит 1 элемент, начиная с элемента с индексом 1
arr // [1, 3]
```


Expand Down