Posted By

ursdeep on 06/02/15


Tagged

javascript delete array code length operator Unary


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ursdeep


delete Operator don’t impact the length of Array in JavaScript


 / Published in: JavaScript
 

URL: https://techfiddler.wordpress.com/2015/06/02/delete-operator-dont-impact-the-length-of-array-in-javascript/

delete Operator don’t impact the length of Array in JavaScript

  1. Ref: https://techfiddler.wordpress.com/2015/06/02/delete-operator-dont-impact-the-length-of-array-in-javascript/
  2.  
  3.  
  4.  
  5. var fruits = ["Apple" , "Banana", "Grape", "Litchi", "Mango", "Orange"];
  6.  
  7. console.log(fruits.length); //prints 6 as there are six elements
  8. console.log(fruits[3]); //prints Litchi
  9. delete fruits[3];
  10. console.log(fruits.length); //still prints 6
  11. console.log(fruits[3]); //prints undefined

Report this snippet  

You need to login to post a comment.