This is not entirely correct. Most certainly a nuke going off in the atmosphere will be much more destructive due to the shock wave propagating in the atmosphere. However a nuke going off in close proximity to a target in space will still have vastly more effect than a conventional explosive. The nuke itself will vaporize with insane force creating destructive pressure from it's own ultra high velocity exploding atoms to anything nearby. Far more destructive however will be the thermal flash of the nuke, literally explosively vaporizing the surface of anything nearby.Actually, nuclear warheads are crap in space.
Virtually all of their destructive power comes from being in an atmosphere where the radiation they cause creates a blast wave. In space, no atmosphere means no blast wave means a nuclear bomb is nothing but an EMP weapon with some radiation.
It is this last effect, the thermal flash explosively vaporizing the surface of a target, that permits the idea of using nukes to move asteroids or comets out of a collision path with the Earth.