It is my understanding that bear spray is not allowed in some national parks, for example, Yosemite.

Almost all my bear encounters have been in Yosemite. One day I ran into 8 bears in about 4 hours of hiking. All the encounters have turned out OK. My last run-in (two weeks ago)was on the north boundary of Yosemite, with a mother and cub. I was solo, saw them first, started making low level noise. The mother bear stood up, the baby ran downhill, I turned and slowly walked uphill and never looked back.

Bears are afraid of people where they are hunted. In National Parks with only black bear, where hunting is not allowed, bears are either defending their young, looking for human food, acting territorial, or curious. I have had a curious bear smell my face while I was sleeping out in the open. I have had more threatening encounters with moose. Those guys are really aggressive.

I carry bear spray, where it is allowed. I would also use it on a moose if needed.