Is there any advantage to adding salt to onion while frying itself rather than adding it the last? My friends say it removes moisture from onion.
Is it true? Why is removing moisture from onion important?
It is true, in my experience. However, if your recipe does not require salt, you should not be adding it, of course. Removing moisture from onion with the aid of salt helps it reach its desired state (brown or translucent, as desired) faster.
I am most familiar with the use of onion in Indian cooking. I generally add a pinch or two of salt to onion when I start sauteing it. Onion starts sweating as soon as you add salt and start stirring.
The reason that salt draws out moisture from onion is osmotic pressure. The surface of the onion acts as a semipermeable membrane barrier. Since the solution outside the onion is more concentrated with respect to salt, water moves out of the onion to the general liquid side, to balance the osmotic pressure on either side of the onion surface.
Adding salt while frying onions has two advantages.
As @Avinash said, salt helps draw water from onion. As the onion cooks in it's own juices we obtain that caramalized or translucent texture. Alternatively, small quantities of water can be added to obtain the same goal, albeit much slower.