Skip to content

Commit

Permalink
update(JS): web/javascript/reference/global_objects/array/shift
Browse files Browse the repository at this point in the history
  • Loading branch information
undead404 authored and AdriandeCita committed Dec 25, 2022
1 parent b9acbcc commit e47c78c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Array.prototype.shift()
slug: Web/JavaScript/Reference/Global_Objects/Array/shift
page-type: javascript-instance-method
tags:
- Array
- JavaScript
Expand Down Expand Up @@ -63,12 +64,12 @@ console.log("Усунуто такий елемент:", shifted);
Метод shift() нерідко застосовують всередині умови циклу while. В наступному прикладі кожна ітерація прибирає з масиву наступний елемент, поки він не стане порожнім:

```js
const names = ["Артем", "Олександр", "Максим", "Богдан", "Назар"];
const names = ["Артем", "Владлен", "Максим", "Марія", "Фахрудін"];

while (typeof (i = names.shift()) !== "undefined") {
console.log(i);
}
// Артем, Олександр, Максим, Богдан, Назар
// Артем, Владлен, Максим, Марія, Фахрудін
```

### Виклик shift() на об'єктах-немасивах
Expand Down

0 comments on commit e47c78c

Please sign in to comment.