Taking out a loan against your 401K is usually a less expensive option than a straight withdrawal where you may have to pay income taxes and a 10% penalty, however there pitfalls that you must take into account.
Most plans will give you only five years to repay the loan. If you borrow a large amount the payment could be substantial.
If you fail to make the payments or leave your company you may be required to pay back the outstanding balance within 60 days or be forced to take it as a hardship withdrawal that will incur taxes and penalties.
Make sure you understand all of the consequences of borrowing against your 401K.