A higher order function is a function that takes one or more functions as arguments, or returns a function as its result.
An important difference between function declarations and class declarations is that while functions can be called in code that appears before they are defined, classes must be defined before they can be constructed.
class
hoisting
Classes defined using a class declaration are hoisted, which means that JavaScript has a reference to the class. However the class is not initialized by default, so any code that uses it before the line in which it is initialized is executed will throw a ReferenceError.
const p = new Rectangle(); // ReferenceError
class Rectangle {}
This occurs because while the class is hoisted its values are not initialized.
Function and class expression hoisting
Function expressions and class expressions are not hoisted.
What are your thoughts on this post?
I’d love to hear from you! Click this link to email me—I reply to every message!
Also use the share button below if you liked this post. It makes me smile, when I see it.