Better by far, where I got r-49 insulation, I could spray open cell and get r-58 or closed cell and get nearly r-100. It also by nature seals the cavity, where fiberglass can have air moving all around it if cut improperly or the cavity is too big. Which means the spray foam will save more for you beyond the R value.
However it comes at a cost. I spent 300 dollars total Insulating. R-19 on the floor, r-26 on the walls, r-30 on half the ceiling, and r-49 on the other half. To fill the same cavities with foam diy kits, I would be looking at over 2k possibly more. Now to get the same r value I wouldn't need to fill the whole cavity technically. But to me the cost savings of the cheaper install and not having to expose the orginal wall far out weighed what I would save in heat retention.
If you are paying to have someone else install and doing new construction the cost difference won't be nearly as great and might be worth spending the extra.