This content originally appeared on DEV Community and was authored by Christian Falucho
Today's progress?
Did some more exercises on constructors from freeCodeCamp.
What I learned
Constructors are functions that create new objects and they define properties and behaviors that belong to the new object.
They are to be defined with a capitalized name to distinguish them from other functions that are not constructors
.
Here is an example of the Car constructor capitalized.
function Car(){
}
Constructors use the keyword this
to define properties of the object they will create. Referring to the new object they will create.
function Car(){
this.color = "black";
this.make = "Lexus";
this.model = "IS 250";
}
This content originally appeared on DEV Community and was authored by Christian Falucho
Christian Falucho | Sciencx (2021-06-20T21:55:13+00:00) Day 5 of #100DaysOfCode!. Retrieved from https://www.scien.cx/2021/06/20/day-5-of-100daysofcode/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.