add arrays example

This commit is contained in:
Alexander Popov 2021-11-19 03:40:21 +03:00
parent 5d4376978a
commit c174bc588e
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
2 changed files with 20 additions and 0 deletions

View File

@ -1,6 +1,9 @@
# JavaScript # JavaScript
## Basic ## Basic
- [Arrays](arrays.js) - работа с массивами
## Other
- [Webpack](webpack.md) example config - [Webpack](webpack.md) example config
## Canvas ## Canvas

17
JavaScript/ararays.js Normal file
View File

@ -0,0 +1,17 @@
let cats = ['Bob', 'Willy', 'Mini'];
// pop(): Remove an item from the end of an array
// pop() returns the removed item
cats.pop(); // ['Bob', 'Willy']
// push(): Add items to the end of an array
// push() returns the new array length
cats.push('Mini'); // ['Bob', 'Willy', 'Mini']
// shift(): Remove an item from the beginning of an array
// shift() returns the removed item
cats.shift(); // ['Willy', 'Mini']
// unshift(): Add items to the beginning of an array
// unshift() returns the new array length.
cats.unshift('Puff', 'George'); // ['Puff', 'George', 'Willy', 'Mini']