DEV Community

Discussion on: Interview Questions for the Javascript Developer: Hoisting, Prototypal Inheritance, and Attribute vs. Property

Collapse
 
antogarand profile image
Antony Garand • Edited

Few notes:

  • Hoisting only happen with var and with functions, where the last function with a given name is called
  • Primitives:

primives (numbers, strings, booleans, undefined, and null)
There are two other: bigint and Symbols (MDN link)

  • You can have actual classes in javascript, using class Dog {}
Collapse
 
ogonommo profile image
Stoyan Peshev

Actually all declarations are hoisted. Trying to access variables declared with let and const before the declaration will hit the temporal dead zone and will throw.

Collapse
 
arrogar profile image
Robbie Datkov

Friendly reminder that the "classes" are just syntax sugar.

Collapse
 
bcaruthers profile image
Bryant Caruthers

Hi Antony,

Thank you for taking the time to read my article and to leave a comment. I did forget to include bigint and symbols. In regards to hoisting, only function declarations are hoisted. Function expressions do not get hoisted by JavaScript. When it comes to variables, var, let, and const are all three hoisted by JavaScript, but let and const throw an error, as Stoyan stated.