I'm doing a codeacademy.com lesson, specifically: "Javascript > Introduction to Objects I > Custom Constructors (21/33)"
In this lesson we're learning how to create constructors, like so:
function Person(name, age) {
this.name = name;
this.age = age;
}
var bob = new Person("Bob", 27);
My question is, how can the constructor exist later on without first being placed into a variable? I'm very, very new to javascript but it was my understanding that unless you stored something in a variable it couldn't persist.
Is this like, a class declaration? Maybe this is only possible with Class
es?
Hoping this question might shed some light in the dark on my understanding of javascript syntax. Thanks.