How can I remove elements from JavaScript arrays?

Learn methods for array management such as length, pop, shift and slice and of course, delete.

By Craig Buckler
September 6, 2016
Removing elements from JavaScript arrays screen Removing elements from JavaScript arrays screen (source: O'Reilly)

JavaScript developers will run into many scenarios that require their arrays to be dynamic. How does one delete an existing array element? Experienced trainer Craig Buckler outlines all of the tools programmers have at their disposal to complete this essential task. Novice level developers with a basic understanding of arrays will be able to follow along easily as Craig demonstrates each method using jsconsole.com.

First, Craig addresses JavaScript’s built-in delete statement, which often trips up new programmers with it’s “undefined” output. The pop, length, shift, and slice methods are also demonstrated. Craig even goes as far as to show you how to replace your removed elements with new ones using the splice method.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Take the next step with JavaScript with our Beginning JavaScript Learning Path.


Craig Buckler is an experienced Web Developer working in the UK. Craig started his career creating desktop software before moving over to the web development. Craig has worked for a number of well-known companies, including Microsoft, MSN, Thomson Reuters, and the UK & EU governments. Craig is the prolific author of countless articles and tutorials on HTML5, CSS3, JavaScript, JQuery, PHP, and Node.js.

Post topics: Web Programming
Post tags: Questions
Share: