For a long time, presidential humor was predictable as a knock-knock joke. Then along came President Obama, dropping the word “heezy,” mimicking viral memes, and quipping that he and Joe Biden are so close, they’d probably be denied service at an Indiana pizza joint.

Obama, who will take the stage at the annual White House Correspondents’ Association Dinner on Saturday to deliver the traditional joke-filled monologue — the eighth and final of his administration — has a comic sensibility that’s edgier and more pop-culture-influenced than we’re used to hearing from politicians.

From the dinner dais, he’s made reference to drunk-texting and “The Hunger Games.” He’s used the phrase “piss off” and flirted with even bluer material. (Does he have a bucket list for his final year? “Well,” he quipped at the 2015 dinner, “I have something that rhymes with bucket list.”) Outside the dinner, he’s mocked the New York Times food section on Twitter (“respect the nyt, but not buying peas in guac”) and sparred with Zach Galifianakis on his culty “Between Two Ferns” faux-talk show.

He might not be the first truly post-racial president after all — but Obama is arguably the first postmodern humorist to hold the office.

George W. Bush and Bill Clinton both possessed easy senses of humor and could deliver a punchline. But Obama’s style, comedy writers say, belongs to the alternative comedy subgenre — a style of humor that breaks with traditional stand-up, loosely defined by irony, self-awareness, and quirky topical references. Think more Sarah Silverman and less Henny Youngman.

President Obama will make his final remarks at this year's White House Correspondents' Association dinner. Here's a look back at some of his funniest moments. (Victoria Walker/The Washington Post)

“He’s not into the classic hokey punchlines,” said Brian Agler, a comedian and speechwriter at the Washington-based West Wing Writers. “There’s a level of detachment and a level of understanding about what’s going on, like, ‘this is kind of weird that the president is up here in a tux making jokes’ — all of his humor has that element baked into it.”

Take this bit from his 2011 White House Correspondents’ Association dinner performance poking fun at the “birthers” who, against all evidence, allege that Obama was actually born in Kenya — among them Donald Trump, who sat in the audience that night. After promising the room that he was about to reveal his “birth video,” he rolled a clip from the African-set cartoon movie “The Lion King.”

Which might have been funny enough on its own. The crowd roared. But Obama added a deadpan flourish.

“That was a joke,” he intoned, pausing for effect. “That was not my real birth video. That was a children’s cartoon.”

That’s what humorists call a “meta” moment: It’s a joke about making a joke. Get it?

At last year’s dinner, Obama was joined onstage by comedian Keegan-Michael Key, in character as the president’s “anger translator,” a recurring gag on his Comedy Central sketch show, “Key & Peele.” As Obama spoke soberly, Key acted out his unspoken and decidedly un-PC thoughts.

Obama, calmly: “Despite our differences, we can count on the press to shed light on the most important issues of the day.”

Key, agitated and loud: “And we can count on Fox News to terrify old white people with some nonsense! ‘Sharia law is coming to Cleveland! Run for the damn hills!’ ”

The president’s reputation as a funny guy is, of course, partly courtesy of the professionally crafted material he reads off the Teleprompters. It’s no secret: A team of speechwriters writes his correspondents’ dinner routines for him. But Obama has input in that process, said David Litt, a former White House speechwriter who’s now the head writer at the Washington office of comedy website Funny or Die.

Writers consult with the president in the weeks leading up to the dinner to get a sense of the punchlines he likes — and those he doesn’t. Then the boss tweaks the final version. “He would make these little, small changes, but they would make such a difference,” Litt said. “They would punctuate the joke in a way that made it work better, or replace a phrase with a slightly better phrase.”

Obama has gotten plenty of unscripted laughs, too. During last year’s State of the Union address, Republicans cheered after he said he had no more elections to run. “I know, because I won both of them,” Obama zinged back. Those mic-dropping words didn’t appear in the advance copy of his remarks.

And as any comic will tell you, timing is everything, even when the words aren’t your own. During the 2015 traditional White House ceremony in which the president pardons a turkey, Obama’s remarks were standard har-har material: “It’s hard to believe that this is my seventh year of pardoning turkeys. Time flies, even if turkeys don’t.” Ba-da-bum.

But his delivery — arch, cut with sarcasm —  conveyed what the words might not have made clear: The president thought the entire thing was completely absurd.

One stylistic tic, a student of Obama’s performances might note, is his tendency to laugh at his own jokes as he’s making them. Too much self-amusement is considered a no-no among comedians, but Obama, the pros say, makes it work. “He has this wry smile,” Agler said. “He 100 percent knows what he’s doing there.”

Obama’s own tastes in stand-up are illustrative. During a podcast interview with comedian Marc Maron, Obama professed a love for comedy, citing as favorites Richard Pryor, Dick Gregory (“when he was on the edge”), Jerry Seinfeld and Louis C.K. He described the latter as “wonderful in such a self-deprecating, but edgy kind of way. And basically good-hearted even when he’s saying stuff that’s pretty wrong, you know?”

According to professionals, Obama has learned a few tricks from his idols.

“He has great timing, and that is something you cannot fake,” said Stephanie Laing, a former executive producer and director of HBO’s “Veep” and the founder of the online women’s comedy platform PYPO. “He’s not goofy. It’s a quiet, very sophisticated humor.”

No less an expert than Seinfeld himself praised Obama’s comedic skills. He included the president in his series “Comedians in Cars Getting Coffee,” insisting that Obama is, in fact, a professional. “He’s done some really good work as a monologist at those correspondents’ dinners — that’s how he qualifies to be on the show,” Seinfeld said.

Obama’s comfort with this kind of humor is likely one reason for the surprising number of his comedic performances. In addition to his dinner speeches, he has been a frequent guest on late-night talk shows, from “Letterman” to “The Daily Show,” where he banters and fields questions about walking around the White House in his underwear. He’s slow-jammed the news with Jimmy Fallon and read mean tweets about himself on “Jimmy Kimmel.”

But the laughs often aren’t for their own sake. Obama has used comedic venues to advance his agenda, particularly among young people who are more likely to share a viral video than watch one of his speeches.

On the “Between Two Ferns” segment and in a Buzzfeed video where he brandished a selfie stick, the president encouraged young people to sign up for Obamacare health coverage. The news he slow-jammed on Fallon’s show was about his student-loan initiative.

Obama’s bone-dry comedic stylings aren’t without risk. They carry the potential to come off as mean.

At the 2013 dinner, he took a jab at the Republican Senate majority leader. “Some folks still don’t think I spend enough time with Congress,” he said. ” ‘Why don’t you get a drink with Mitch McConnell?’ they ask. Really? Why don’t you get a drink with Mitch McConnell?”

McConnell later tweeted a picture of himself at a bar, enjoying a beer, with an empty barstool beside him.

And the commander-in-chief’s style can fuel the criticisms that have long dogged him — that he is snooty and detached. Which, in Obama’s comedy world, is simply another opportunity to go meta.

“Some people say I’m arrogant, aloof, condescending,” the president said at last year’s dinner.

He paused.

“Some people are so dumb.”