Not all 401(k) plans allow loans. You will have to check your plan's SPD (Summary Plan Description), available from your HR department.
Keep in mind that 401(k) loans can be one of the worst ways to borrow money.
First of all, most plans do not allow you to continue making payments if you terminate employment. The balance becomes immediately due, and if you can't pay it, you will end up paying income taxes plus the 10% early withdrawal penalty on the unpaid balance. That tax bill can make a job loss hurt even worse.
Second, the loan payments will amount to double-taxation of your retirement withdrawals. You will be repaying the loan with after-tax money, plus paying income tax again when you withdraw that money upon retirement.
Third, there can be a large opportunity cost in removing that amount from the compounding investment growth.
I'd recommend a 401(k) loan only as a last resort.