get last before value from array

get last before value from array

hi all,
 i am pushing  array elements as dynamically i need last before array value every time..
ex:
var array=[1,2,3,4,5,6,7,8,9,10]
 i need 9 
if i have 3 var array=[1,2,3] <=== this time i want 2
var array=[1,2] <===this time i want 1

i tried like this                                      
array=[1,2,3,4,5,6,7,8,9,10]
console.log(array[array.length-1]) it is giving 10
if i put array.length-2 it is giving correctly..but i don't want manual entry..