He is just 18 months old. They don't understand how hitting hurts you. Time outs do not work at this age, they are for much older kids. Hitting back only works for the moment, but condones the hitting behavior in the long run.
So next time when he hits you, you should instantly walk away from him, saying something to the effect: "What you have just done has hurt me, and so mama cannot have any more fun with you. I cannot play with you or talk to you. I still love you, but we cannot have fun together when you hit me."
The idea is to take away from him, what he values the most: your attention.
I am sure he will follow you or will beg you not to go away. Then you just need to sit in the same room, but physically disconnected from him and talk to him in a serious and sad tone that if he hurts anyone, nobody will want to have fun with him, because hitting and hurting others is bad behaviour.
Do mention to him that he is a good boy, but with some bad behavior ..... that you can help him wash away the bad behavior from him hands (the ones that hit & slap) ..... go ahead and wash his hands with soap. While washing, talk to him about sending the bad behavior down the drain!
If you are consistent with this strategy, it should take about 2 weeks to dramatically reduce his unwanted behavior. When he doesn't hit (where he normally would have), do remember to praise him verbally.
Also, if your boy hits some other child, instantly apologise to the other child, without making any eye contact with your son. Do not talk to your son at all, for a few minutes, instead, spend time sympathizing with the hurt child and asking if he/she was hurt and then as soon as you can, start playing with the hurt child. The idea here is again, to give no attention to your child (positive or negative). When he tugs at you, tell him: 'hitting is no fun' and repeat what I wrote earlier.