Javascript Tutorial | Constructor Functions | Ep23

preview_player
Показать описание
We've already learn't that objects are important as well as functions. However what about creating an object via a constructor function? This is extremely common place in Javascript as ES5 (or Javascript version 5) doesn't have any class syntax. However the next iteration of Javascript will include the class syntax, but however for now lets review how to make a constructor function.

Also something worth noting we won't be directly working with the console in this lecture. Instead we'll be writing our command's in a Javascript file. We also want to review how to correctly attach a Javascript file to a HTML file and finally how to output information to the console window from our Javascript file. Working with the console will be very useful to you and allow you to look under the hood of how your script's work.

Рекомендации по теме
Комментарии
Автор

Wow, you explained this so well. I finally understand the why and the how regarding constructor functions. Thank you!

alexzahrai
Автор

Best explanation of constructor functions out there.

teenytinytoons
Автор

Thanks Sir Avelx for to the point explanation

uubaidullah
Автор

i was looking for this concept and this was what i got the best.thanks a lott

pratheekhebbar
Автор

how to add array of random numbers to the instance

osamation
Автор

Now it makes sense. Thank you, thumbs up and subscribed

traynor
Автор

no unnecessary garbages right on the topic, clear voice, no keyboard stroke annoying sound everything went so perfect.

ahwaliazizi
Автор

ONCE THE CLASS CONSTRUCTOR IS CALLED AND CREATES THE NEW OBJECT, HOW DO I GET THE NEW OBJECT INTO AN OBJECT ARRAY???
HOW DO I GET A NEW PERSON OBJECT FROM THE NEW PERSON CONSTRUCTUR INTO THE PERSONS ARRAY???

vegasvato
Автор

Explained really well! Nice video! After trying your code i consoled window object!
It's showing like this
Apple:function Apple(x, y, color, score)
apple1:Apple
apple2:Apple
apple3:Apple

But inside Apple i have prototype object also In that object it has the same Apple function as a constructor! May i know why?? Can you explain it little bit more?? Or give some resource to understand it please!!

kaushikchelladurai
Автор

im confuse
when we create object using new keyword object creates ....
so why object return
let a = New Apple() // object is already here ...
what function returning

shadow