How does JS compare the numerical size of an uncertain number of targets?

how does RT:JS compare the numerical size of an uncertain number of targets?

const rects = [
    {width: 12, height: 34},
    {width: 9, height: 32},
    {width: 32, height: 64},
    {width: 13, height: 84},
    {width: 2, height: 94},
]

rects.forEach(item => {
    item.height //
})

what I can think of is to compare one by one step by step, save the maximum value before the order and then compare it with the next value. Is there a simple way to achieve it?

Mar.07,2021

  

call the sort method in the array to sort. If you want to sort in descending order, just go to the first one

.
Menu