This is true to an extent. While for objects of uncertain structure you should use more complex methods — for simple object comparison you can use stringify passing a key order as second argument.

const a = {a: 1, b: 2}
const b = {b: 2, a: 1}
console.log(
JSON.stringify(a),
JSON.stringify(b)
)
// {"a":1,"b":2} {"b":2,"a":1}
console.log(
JSON.stringify(a, Object.keys(a).sort()),
JSON.stringify(b, Object.keys(b).sort())
)
// {"a":1,"b":2} {"a":1,"b":2}

It’s not a matter of should and shouldn’t, but of knowing the interface of the methods you do use and making a conscious decision.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store