Jennifer Lopez said Thursday she would "walk out" if she found out Ben Affleck was having an affair. 

The "Shotgun Wedding" star, who married the "Air" actor last summer, was asked the hypothetical on "The View" while the co-hosts were discussing "Vanderpump Rules" star Tom Sandoval’s alleged affair with Raquel Leviss when he was with Ariana Madix. 

"I think I'd just walk out. Just walk out," Lopez said. "You know everything you need to know. What else do you need to know?"

The 53-year-old, who admitted she’s "seen" the reality show but doesn’t watch it regularly, reacted in surprise when Joy Behar told her what was going on with the show.

GWYNETH PALTROW SAYS BEN AFFLECK WAS ‘EXCELLENT’ IN BED COMPARED TO BRAD PITT 

Jennifer Lopez and Ben Affleck looking at each other

Jennifer Lopez said she'd leave a husband who'd had an affair.  ( Daniele Venturelli/WireImage)

"So what would you do if your friend was sleeping with your husband?" Behar asked.

"Is that’s what’s happening on ‘Vanderpump Rules?'" Lopez asked as the audience laughed. 

She reiterated the affair would be "all the info you need" to leave after Behar asked her if she would be "violent" or "rational" if faced with that situation. 

Lopez opened up about her thoughts on cheating in 2015 while discussing her romantic thriller "The Boy Next Door" about a couple caught up in infidelity. 

"I think it's about realizing it's not about you. When someone cheats on you, it's about them ... about their shortcomings," the "Marry Me" actress told Glamour UK at the time. 

Jennifer Lopez posing with Ben Affleck

Jennifer Lopez and Ben Affleck married last summer.  (Jon Kopaloff/Getty Images)

The actress admitted she has been cheated on in past relationships in another interview that same year. 

"I've been in relationships where there has been infidelity, and you’re left to feel like you did something wrong," she told Loaded magazine of her unnamed unfaithful exes, according to the Daily Mail. "Like there’s something wrong with you, you’re not enough, all of those feelings that we struggle with." 

BEN AFFLECK ‘DISTURBED’ BY WIFE JENNIFER LOPEZ'S LOVE OF ‘YELLOWSTONE’

Ben Affleck looking at Jennifer Lopez

Lopez admitted in 2015 she's been cheated on in past relationships but didn't name names.  (Arturo Holmes/Getty Images)

Madix had been in a years-long relationship with Sandoval when she reportedly found out earlier this year he had been having an affair with Leviss, her friend, for months. They broke up, and Leviss has apologized, writing on her Instagram that she took responsibility for her actions and admitted she has "sought emotional validation through intimate connections that are not healthy."

Sandoval also posted an apology on his Instagram, saying he was "selfish" and "reckless."  

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

Tom Sandoval smiling with Ariana Madix

Tom Sandoval, left, and Raquel Leviss, not pictured, have apologized to Ariana Madix, right, amid cheating accusations.  ( Amanda Edwards/Getty Images)

CLICK HERE TO GET THE FOX NEWS APP

Lopez was married three times prior to Affleck to Ojani Noa, Cris Judd and Marc Anthony, which whom she shares her twins Emme and Max. 

Fox News Digital has reached out to a rep for Lopez for comment.