Hello I'm new to javascript.
I was trying to reduce the length of an array by 1.
I did this, the last element is undefined now, but the length is still 5.
var arr = [1, 2, 3, 4, 5];
arr.length = arr.length--;
console.log(arr);
console.log(arr.length);
I'm confused. Instead of [1, 2, 3, 4] or [1, 2, 3, 4, 5]. Why it gives me [1, 2, 3, 4, undefined]?
Can someone explain? Thanks