However, assuming that the cartridge design is identical, the handgun is identical, they are being used by the same shooter and the overall scenario is the same wouldn’t the .40S&W be a better option?
No 9 times out of 10 (from what I've seen with others, sit back down!) you will shoot one better than the other.
One has muzzle flip and keeps rising. One doesn't have it as dramatic as the other.
9mm is easier to shoot.
Unless every self defense scenario you have in your mind will be an assailant standing still and you sitting down and shooting from a bench rest.
Then the 9mm is a wiser decision.
Unless...you want to spend all the time and money in something that will take you longer to get accustomed to as opposed to something that won't take you as long to get accustomed to.
Sáncte Míchael Archángele, defénde nos in proélio, cóntra nequítiam et insídias diáboli ésto præsídium. Ímperet ílli Déus, súpplices deprecámur: tuque, prínceps milítiæ cæléstis, Sátanam aliósque spíritus malígnos, qui ad perditiónem animárum pervagántur in múndo, divína virtúte, in inférnum detrúde. Ámen