As per the title, how does JS sort an array of objects without using a compare function?
For example:
const bookshops = [{
id: 3,
name: 'bookshop3',
imgSrc: 'https://www.google.com/'
}, {
id: 8,
name: 'bookshop8',
imgSrc: 'https://www.google.com/'
}, {
id: 2,
name: 'bookshop2',
imgSrc: 'https://www.google.com/'
}, {
id: 9,
name: 'bookshop9',
imgSrc: 'https://www.google.com/'
}, {
id: 4,
name: 'bookshop4',
imgSrc: 'https://www.google.com/'
}, {
id: 6,
name: 'bookshop6',
imgSrc: 'https://www.google.com/'
}, {
id: 10,
name: 'bookshop10',
imgSrc: 'https://www.google.com/'
}, {
id: 7,
name: 'bookshop7',
imgSrc: 'https://www.google.com/'
}];
bookshops.sort();
console.log(bookshops);
What will be the output? Did "bookshops" get sorted?
"[object Object]"for each of them, so technically they'd all be equal.