When the above code is executed, the following output is generated.
Before shifting ------------- Jag Chat Win Dhan
After shifting ------------- Chat Win Dhan
The above code is very similar to the code available in previous section with only the following change:
Earlier, in the previous section, I used the “pop” method. When we apply “pop,” the last element (or the latest element added at the end of the array) gets deleted from the array automatically. But when we apply “shift,” the first element present in the array gets deleted. Apart from this difference, the rest of the code is quite similar.