There is no stack in JavaScript, but there is an array that can be used as a stack. At the same time, by manipulating the JavaScript push / pop array methods , you can have at your disposal a stack, an array, and your own data organization.
As a first approximation, arrays are a familiar and popular data structure. But working with them as a stack gives them capabilities not provided by the syntax of the language. Adding / removing via JavaScript push / pop to the end or unshift / shift to the beginning is not only convenient, but also practical.
Using methods
The array can be replenished with new elements using the push method. The result of this method will be a new number of array elements. The reverse procedure - the pop method has no parameters, but returns the last element of the array as the result.
, .
JavaScript push object - ?
ยซยป - , . , -, , .
, , JavaScript, ยซยป . - - , .
JavaScript pop&push .
, , (, ), . () push ( ), .
push , . pop . - push, . , .
,
, . if case, , ยซยป .
, - , , , , , .
.
: . - ( ):
( ), JavaScript push .
Search by line in line is always more visual than numerous conditions. This is a simple case of only three by three options, but even here there will be much more code than in one comparison of just two lines.