How can I remove elements from JavaScript arrays?
Learn methods for array management such as length, pop, shift and slice and of course, delete.
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.
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.