It is an adverbial locution, which comes to say of doing something that is done without thinking, without making a premeditated decision and in a great hurry.