DEV Community

Cover image for How to Remove Last Element from Array in Javascript?
Code And Deploy
Code And Deploy

Posted on


How to Remove Last Element from Array in Javascript?

Originally posted @ visit and download the sample code:

In this post, I'm sharing a short post on how to remove the last element value from an array in Javascript. If you need to remove the last value of the array before processing the data then array.pop() done this.

Here is the example solution below:

var websites = ['', '', ''];



// result: ["", ""]
Enter fullscreen mode Exit fullscreen mode

I hope this tutorial can help you. Kindly visit here if you want to download this code.

Happy coding :)

Top comments (0)


11 Tips That Make You a Better Typescript Programmer

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields


Read the whole post now!