Why is salt sometimes ingredient of otherwise sweet cookies?
Great question.  the salt is not there for the taste of salt. A pinch of salt helps with the ionization process so your taste buds can pick up the tsate of the chocolate, ice cream, etc, better.

I think this was discussed in an episode of Alton Brown's Good Eats as well.