I think a few years back most people would take a
trip to Las Vegas spontaneously as there wasn't a destination like Vegas that was as easy to fly to, as inexpensive to fly to.
The thing is that now most people know about Vegas, so booking in advance is necessary to get the best value. I'd say plan three weeks to a month in advance to ensure that a cheap flight is still available.
As far as hotel rooms, Las Vegas likely has one to spare whether you book a month in advance or walk up to the desk.