can please explain to me this step by step
Var a = []; a.unshift(1); a.unshift(22); a.shift(); a.unshift(3,[4,5]); a.shift(); a.shift(); a.shift(); The final output for the shift() is
Unshift adds element at the start of array and shift removes element from start of array
a.unshift(1) -> [1]
(1 added in array)
a.unshift(22) -> [22, 1]
(22 added in array)
a.shift() -> [1]
(22 removed from array)
a.unshift(3,[4,5]) -> [3, [4, 5], 1]
(3, [4, 5] added in array)
a.shift() -> [ [ 4, 5 ], 1 ]
(3 removed from array)
a.shift() -> [ 1 ]
([4, 5] removed from array)
a.shift() -> []
(1 removed from array)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.