Please be careful with 401(k) loans. You’re borrowing your own money and paying yourself “interest” as you repay the loan. It’s not the same thing as earning money on your investments. The hidden cost of 401(k) loans comes from the earnings you’re not receiving on your savings while they’re borrowed from your account. The interest you pay yourself is not a true interest expense since you’re paying it to yourself and its definitely not tax deductible.
And one of the things that motivated me to borrow the money in the first place was that I specifically drew down part of my U.S. bond fund to provide cash for the loan. That fund was earning such miniscule interest anyway, so I don't see the withdrawal of the money as much of a "lost" opportunity at all.