defer is a statement used to execute a block of code just before the current scope e.g a function or loop exits.