What is hoisting?

Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution.

Guide

Valid snippet because of Hoisting

console.log('a', getItem()); // Function getItem is accessible even before it is declared.
Function & variable declarations are always hoisted in JS.

function getItem ( ) {
    return { a: 10 };
}

Hoisting won't work

console.log('a', getItem()); // Functions, variables declared using 
const & let keywords are never hoisted. Copilation error will be encountered.

const getItem = ( ) =>  {
    return { a: 10 };
}