views:

54

answers:

1
var arr = [1,2,3,4];

I need to get the last one and then delete it from an array called arr:

var arr = [1,2,3]
+5  A: 

You want to do exactly what the pop method does:

var arr = [1,2,3,4];
//...
var last = arr.pop(); // returns 4, and arr will contain now [1, 2, 3]
CMS