kapayapaan's post sums it up, but also wanna add this.
And if any man's seed of copulation go out from him, then he shall wash all his flesh in water, and be unclean until the even.
-Leviticus 15:16
Seed of copulation is sperm by the way. Unclean, in constant meaning, means not fit to be in the presence of God. You gotta be clean. So what does that say on masturbation?