Molly and Amy have spent their entire time in high school concentrating on two things: academics and each other. But on their last day of classes, from a stall in the bathroom, Molly — senior class president and valedictorian — overhears some other kids making fun of her.

She listens, is wounded, then bursts out to confront them, besting their condescension with her own. She tells them, essentially, “Oh, yeah, well, I’m going to Yale!” When one of the students replies, “So am I,” and the others chime in that they’re going to Stanford and Georgetown, Molly can’t believe her ears. How could these kids, who partied their way through school, possibly be smart enough to get into good schools, too? The moment rocks Molly so much she decides she and Amy have to squeeze four years of fun into one night by going to a pre-graduation party thrown by one of the popular kids.

Thus begins “Book Smart,” a coming-of-age story that plays out like similar sagas, but has a wit and sense of humor all its own. It’s not the first movie in the genre to have female leads (Jennifer Jason-Leigh and Phoebe Cates in “Fast Times At Ridgemont High,” Alicia Silverstone and friends in “Clueless,” Lindsay Lohan et al in “Mean Girls”), but it is contemporary, funny, and offbeat. First-time director Olivia Wilde isn’t afraid to play with the form, as in one sequence where she switches to animation when the girls accidentally ingest a psychotropic drug.

The movie, written by four women — Susanna Fogel, Emily Halpern, Sarah Haskins, and Katie Silberman —¬†understands who Molly and Amy are, and surrounds them with just enough wacky supporting characters to drive the story. Wilde has perfectly cast her leads: Beanie Feldstein, the best friend in “Ladybird,” plays Molly; and Kaitlyn Dever, so good as Loretta McCready on “Justified” and Jayden in “Short Term 12,” is Amy. Their natural chemistry had me believing these were lifelong friends who loved each other, even when a twist threatens to drive them apart.

The supporting cast includes Jessica Williams as the cool teacher, Jason Sudeikis as the bedraggled principal, Lisa Kudrow and Will Forte as Amy’s parents, and Mike O’Brien as an oddball pizza delivery guy. If you listen carefully, you might also catch a voiceover by Maya Rudolph just as the movie begins.

I’m obviously not the target demographic for “Booksmart,” but I still enjoyed it enough to give it an 8 out of 10 (if you’re under 30, add one).