Need to shorten an array in JavaScript

When I take off the first item in the array, all I really do is shift the values up one index. Is there an easier way?

Anyway, I have this coded and it works. I would like to shorten the array by 1, so that calling the length property will be correct. How can I do that?

Thanks!
newbiewebSr. Software EngineerAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
var p = myarray.shift();  // put the first item of the array in p and remove it from the array
// http://www.w3schools.com/jsref/jsref_shift.asp
// Remove the first element of an array (this will also change the length of the array)


0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.