const arr = [{name:'Suzanne'},{name:'Jim'},{name:'Trevor'},{name:'Amanda'}];
arr.sort((a,b)=>a.name > b.name);
I want to sort elements(objects) in the array name-alphabetically(A->Z). When I use the code in node(v8.4.0) and safari development tool(console), it works well.
But it doesn't work in chrome development tool-console(v70.0.3538.110). There is a result of code in chrome console.
In my opinion, the code is not wrong. I don't know why the code doesn't work well.
When I use the code in node(v8.4.0) and safari development tool(console), it works well.That's interesting, since the sort method expects a callback returning a number, and the above expression is returning a boolean. The code is not correct or, at least, your code is not supposed to what you're expecting.