Adding elements using "push" in JavaScript
Using the special method push,
you can add elements to the end of an array.
Let's see how it's done. Let's say we have
the following array:
javascriptlet arr = [];
Add three elements to its end:
javascriptarr.push('a');
arr.push('b');
arr.push('c');
Let's see what happened:
javascriptconsole.log(arr); // shows ['a', 'b', 'c']
Задание 1
Fill an array with numbers 1,
2 and 3.
Задание 2
Let such an array be given:
javascriptlet arr = [1, 2, 3];
Add the elements 4 and
5 to its end.