Skip to content

Latest commit

 

History

History
10 lines (7 loc) · 615 Bytes

File metadata and controls

10 lines (7 loc) · 615 Bytes

With 'use strict':

An error occurs: ReferenceError: sayHi is not defined. The function sayHi is declared inside the block (if), so it only exists within that block. In strict mode, functions declared inside a block have block-level scope, similar to variables declared with let or const.

Without 'use strict':

The function sayHi is accessible outside the block. This is because, in non-strict mode (and older JavaScript specifications before ES6), functions declared inside blocks like if, for, etc., are hoisted to the nearest function or global scope, making them accessible outside the block.