Skip to content

Latest commit

 

History

History
51 lines (32 loc) · 573 Bytes

28.Hoisting-II.md

File metadata and controls

51 lines (32 loc) · 573 Bytes

28. Hoisting II

Problem

https://bigfrontend.dev/quiz/Hoisting-II

Problem Description

What does the code snippet below output by console.log?

const func1 = () => console.log(1);

func1();

func2();

function func2() {
  console.log(2);
}

func3();

var func3 = function func4() {
  console.log(3);
};

Answer

const func1 = () => console.log(1);

func1(); // 1

func2(); // 2

function func2() {
  console.log(2);
}

func3(); // Error. Function expressions are not hoisted.

var func3 = function func4() {
  console.log(3);
};