jQuery returns a new object each time it is called with a query selector. When you to == or ===, you are actually checking whether an object reference equals another object reference. In this case, it does not, since jQuery returns a new object each time. It would be the same as this: ({}) === ({}).
In your simple example, you can do this instead:
$('body').is('body')
However, depending on the real problem you have to solve, that may not be the answer. For example, if you need to check if two different selectors resolve to the exact same list of object (no more and no less), then this will not work.
You can do this to check if two selectors both found the one single DOM object:
$('.my-class').get(0) === $('.other-class').get(0)
This will check that the first element found is the same. You should, however, also check that the "length" property of each is 1, because it may not be.
This can get more and more complex, depending on what you actually need to solve.
In your simple example, you can do this instead:
$('body').is('body')
However, depending on the real problem you have to solve, that may not be the answer. For example, if you need to check if two different selectors resolve to the exact same list of object (no more and no less), then this will not work.
You can do this to check if two selectors both found the one single DOM object:
$('.my-class').get(0) === $('.other-class').get(0)
This will check that the first element found is the same. You should, however, also check that the "length" property of each is 1, because it may not be.
This can get more and more complex, depending on what you actually need to solve.