From c174bc588e8977f1b4d14eb96dacfd1c3ce0374b Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Fri, 19 Nov 2021 03:40:21 +0300 Subject: [PATCH] add arrays example --- JavaScript/README.md | 3 +++ JavaScript/ararays.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 JavaScript/ararays.js diff --git a/JavaScript/README.md b/JavaScript/README.md index f421637..c372ca9 100644 --- a/JavaScript/README.md +++ b/JavaScript/README.md @@ -1,6 +1,9 @@ # JavaScript ## Basic +- [Arrays](arrays.js) - работа с массивами + +## Other - [Webpack](webpack.md) example config ## Canvas diff --git a/JavaScript/ararays.js b/JavaScript/ararays.js new file mode 100644 index 0000000..6ccdfcf --- /dev/null +++ b/JavaScript/ararays.js @@ -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']