Everyone with a cellphone and a romantic life knows how swiftly and viciously the phone can turn against you. One minute, it’s a blameless communication device; the next, it’s a toxic incubator of second-guessing and self-loathing. You think you’re a reasonable person; suddenly, you’re obsessing over how to respond properly to a 2 a.m. text from a crush whose only communication after three days of silence reads, in its entirety, “wsup.”

Aziz Ansari feels your pain. He knows how unpleasant it is to stare impotently at a screen waiting for a message that never arrives, how undignified it is to apply a French deconstructionist’s fervor to the analysis of an illiterate string of unpunctuated words. Once, he writes in his new book, “Modern Romance,” a would-be girlfriend’s failure to respond to his effortfully insouciant text sent him spinning helplessly into a “tornado of panic and hurt and anger.”

The hours slouched by. “I’m so stupid!” he writes. “I should have typed ‘Hey’ with two y’s, not just one!” Later: “Did Tanya’s phone fall into a river/trash compactor/volcano? Did Tanya fall into a river/trash compactor/volcano?? Oh no, Tanya has died.” (Oh no, in fact — Tanya just doesn’t feel like answering.)

This is the first book by Mr. Ansari, a stand-up comedian best known for playing Tom Haverford, a hopeless Lothario and jauntily deluded entrepreneur, on the late, great television show “Parks and Recreation.” He decided to write it after he brought up the Tanya debacle in a comedy routine and got to thinking, he says, about the universality of his experience, about “how and why the whole culture of finding love and a mate has radically changed” in the modern era.