let arr=[12,54,3,2];

arr.sort((a,b)=>{
    return a-b;
});

console.log(arr[arr.length-2]);