How to compare a Nikon D40x to a modern mobile phone?

Bring both and compare the results later. You will probably find that the answer is not as black and white as you expected and depends very much on the subject and the scene. Also compare the output on the mobile screen, the good screen of the computer and maybe some impressions.

One thing to note is that cell phone cameras tend to try to give you the kind of result you would get by using a semi-professional camera. and the aggressive treatment, increase in color saturation, noise reduction and emphasis even in "standard" picture modes (the "standard" profile of some phones is more "brutal" than "vivid" in many dedicated cameras).

The free-hand night photography performance of today's state-of-the-art smartphones looks surprisingly good (you will probably find it hard to adapt unless you have a VR-assisted and / or very fast Nikon lens), but the images tend to crumble too aggressive noise reduction when viewed on a normal size monitor.