Leviticus 15 makes it clear that a man is unclean if he releases semen while in sexual relations with his wife. This is from the authors’ interpretation of any emission (ejaculation, menstruation, and even STD emissions) as a release of life force. During this period of uncleanliness, the man is unfit to participate in rituals. As written by the 12th Century rabbi Maimonides
The above references ejaculation in a heterosexual context.
With respect to the tale of Onan, Genesis 38:8-10 isn’t referring to masturbation. It’s referring to pulling out while Onan has sex with his brother’s wife. This is frowned upon, and God kills Onan for this, because semen is prized in heterosexual sex. Even when it doesn’t lead to pregnancy.
Jewish mystical tradition also applied this interrupted coitus view to masturbation as well, and believed that spilled semen led to the creation of demons.
Getting back to the topic of abortion, Exodus 21 and Numbers 5 make it clear that the authors of the Torah didn’t not see the unborn as being equal to living, breathing persons. The punishment for inducing a miscarriage was less severe than for killing a person and the use of a known abortifacient was to be used in testing whether or not a woman had engaged in sex outside of marriage.
Modern day Christians will do some mental gymnastics and claim that in Numbers 5, the woman is only made to drink “bitter water” and that if she did lie and she is pregnant and then does miscarry, it isn’t the priest that caused that death, but rather it’s the child paying with its life for the sins of the mother, that it’s God’s divine punishment and not the concoction causing an abortion.
Here we are: Bronze Age morality being applied to the digital era.