From the course: JavaScript: Classes
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Hoisting explained with classes - JavaScript Tutorial
From the course: JavaScript: Classes
Hoisting explained with classes
- [Instructor] Hoisting is always a subject that is confusing for newcomers. So let's explore this a bit and how it relates to classes. So we're back in the app.js, and just to show you that a class has to be declared before it can be run. Let's go in, copy this code here or all of it actually from 13 to 16 like so. And I'm going to also comment this and add it to the top of the class. Now if I save this and I go back to my server we got an error. So basically we cannot use anything from the class until it actually is declared. So this code will work, this code won't work. So let me delete that. Bring that back on command this and save. And as you can see, everything is running as it should. But what about functions? What if I created a function here that say hi and that function will return? Console log. Hello? This function can be called anywhere. So if I save that and I go to the top here and I run this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Introduction to classes1m 53s
-
(Locked)
Defining a class8m 32s
-
(Locked)
Differences between functions and classes1m 42s
-
(Locked)
Hoisting explained with classes2m 27s
-
(Locked)
Strict mode with classes explained1m 25s
-
(Locked)
What are static methods and usage?4m 11s
-
(Locked)
Prototype methods explained and usage2m 25s
-
-
-
-