/ Published in: JavaScript
delete Operator don’t impact the length of Array in JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Ref: https://techfiddler.wordpress.com/2015/06/02/delete-operator-dont-impact-the-length-of-array-in-javascript/ var fruits = ["Apple" , "Banana", "Grape", "Litchi", "Mango", "Orange"]; console.log(fruits.length); //prints 6 as there are six elements console.log(fruits[3]); //prints Litchi delete fruits[3]; console.log(fruits.length); //still prints 6 console.log(fruits[3]); //prints undefined