401(k) loan should be the last resort. I’m looking at this purely from tax perspective. You will incur double taxation when doing so. Below is a simplistic example:
Now - you borrow $100,000 and your current marginal income tax rate: 30%. The income tax for that 401(k) loan is $30K.
Then you have to pay back the loan.
When you retire and your marginal tax rate is 20% (lower since you no longer work) - when you withdraw $100K, you’ll be taxed again at 20%, or $20K.
Total potential tax paid: $50K. And that doesn’t include the potential 10% tax penalty.