Perhaps this will clarify things:
let a = {}; // Object Literal
let b = {}; // Object Literal
let c = a;
// both a and b above are separate objects
console.log(b == a) // false
console.log(c == a) // true
console.log({} == {}) // false, as both are different Objects
// if you want to test if two things are the same type you could do
console.log(({}).toString() == ({}).toString()) // true
console.log(a.toString() == b.toString()) // true
// the reason why those work is, because now we are comparing strings... not the objects
console.log(({}).toString()) // "[object Object]"
// to simply check that the Object is "true", you could.
console.log(!!{});
// Specifying your own false, if empty comparisons "as values"...
console.log(!!Object.keys({}).length) // false
// or, even
console.log( !("{}" == JSON.stringify({}) ) ) // false
I would caution against using JSON.stringify if there is any chance the object of interest could be a function or contains any non json safe values, as you will get an error in the case of functions or false positives in you comparison
JavaScript Equality
=== is Strict Equality Comparison ("identity")
== is Abstract Equality Comparison ("loose equality")
"===" is simple, are the objects being compared the same object "instance"
"==" is a bit more complicated, as coercion comes into play, so it's more like "can they be the same"
Check out this article which goes into the mechanics of what is going on...
Loose Equals vs. Strict Equals
Loose equals is the == operator, and
strict equals is the === operator. Both operators are used for
comparing two values for "equality," but the "loose" vs. "strict"
indicates a very important difference in behavior between the two,
specifically in how they decide "equality."
A very common misconception about these two operators is: "== checks
values for equality and === checks both values and types for
equality." While that sounds nice and reasonable, it's inaccurate.
Countless well-respected JavaScript books and blogs have said exactly
that, but unfortunately they're all wrong.
The correct description is: "== allows coercion in the equality
comparison and === disallows coercion.