Learn JavaScript Episode #22: Class Constructor, Instance Variables, and Static Variables

preview_player
Показать описание
Get The Learn to Code Course Bundle!

Once our class is created we will need to write a function to call it, and this varies by programming language. In Python you use the init method, in C++, and other C languages, you use the class name, and in JavaScript you use what is called the constructor. This was one the topics when learning object-oriented programming, and maybe I just didn't have the right information, that confused me a bit. So, I hope I have explained constructors, instance variables, and class variables well enough in this video.
Рекомендации по теме
Комментарии
Автор

Some segments in the video are stamped not adjacent to each other

sonhuynhtien
Автор

I'm trying to figure out how to get the user to input the dog as a new object and then input the name, height and weight of the animal.

amnfox
Автор

How to pass in parameters from two different objects?
For example -
dog =new Animal(data1);
fish = new Animal (data2);

where data is
function data() {
this.x = 20,
this.y = 10
}

TheNikhilmishras
Автор

small comment, when you create the object (using new) you litrally calling the constructor function, it doesn't give you any errors if you didn't define the function, because it calls the constructor of its parent (object). once you define the constructor, it override the object's constructor and calls your object constructor.

arielapp
Автор

how did you do it can you share with me, thank you

thanhhoai
Автор

Dear Joe, You would improve your tutorial if you made your font much larger. 24pt is the minimum. Also. You have so much wasted space that's not used to display the code you write. The partial image in the background is very distracting. Finally, show us the completed image, so that we know what we are building. Then give us your line by line explanation. Thank you for sharing. Good luck to you.

basalduat