Generally, pedestrians have a right-of-way. But not anywhere or anytime. The California Motor Vehicle Code 21950 states that drivers “shall yield the right-of-way to a pedestrian crossing the roadway within any marked crosswalk or within any unmarked crosswalk at an intersection.” Thus, as long as pedestrians are crossing a crosswalk at an intersection, they have the right-of-way.
In the same vehicle code, it states that “no pedestrian may suddenly leave a curb or other place of safety and walk or run into the path of a vehicle that is so close as to constitute an immediate hazard”. It means that pedestrians do not always have the right-of-way. Pedestrians must practice due care for their own safety. If the oncoming motorist is too close, then pedestrians shouldn’t walk or cross in front of them.
Both pedestrians and motorists have to exercise due care. It is better if pedestrians do not assume that motorists will give them the right-of-way all the time. If it can help prevent an accident, yield your right-of-way. In return, motorists should respect the right-of-way of pedestrians by being cautious on the road and by obeying traffic laws.