This could be done in part, because the equipment was very inexpensive. Not much money was involved in tooling so that basic changes of that type could be accomplished.
Jim Carrey is a consummate actor and professional. He comes on set, knows his lines and knows his moves.
The message here is you cannot, under any circumstances, throw an object at an official. You just cannot do it.