Class is in Session


HI ,
i never understand it ,even i passed the lesson;
why we need to do this ?
i ever donot understand it .thanks

function Person(name,age) { = name;
  this.age = age;

// Let's make bob again, using our constructor
var bob = new Person("Bob Smith", 30);
var susan = new Person("Susan Jordan", 35);

// make your own class here
function Circle(radius){
    var radius=new Circle(90)


Is this function Person inside a class or is it just alone?


Nothing :grinning: didn’t see the title


Is the class called Person?


yes, it is in the class


yes ,could you explain one time .thanks


The reason you use this.key is because that is how you assign values inside of a constructor. When you call the constructor, with bob, or susan, you can pass their names and ages. It creates the objects, and uses this.key to say “this objects name is equal to the name variable” or “this objects age is equal to the age variable”

it allows you to create dozens of objects of the same class, while giving them different values to make them unique

this is a terrible explanation, but i can try to explain it more in depth if you need me to


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.