10/30 what's the difference between function Circle(radius) and Var Circle = new Object()


#1

Hi guys, my mind was just stuck here. what's the difference between
function Circle(radius) and Var Circle = new Object()
can we use both to define a class?

function Person(name,age) {
this.name = 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){
this.radius = radius;
}


#2

function Circle(radius) in this case is being made to create a class named Circle

var circle = new Circle will be used later to create an instance of the Circle class


#3

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

the above is a constructor function. we use these functions to creat new instances of an object like..
///var Tom = new Person (x, x); therefore, you can creat more than one object type using the constructor function.You can creat multiple objects!

Var Circle = new Object() // on the other hand only allows you to creat a single objects. Most times in creating a new object, you don't have to do this, you can just easily write ///var circle = { property:value };

But using this keeps you limited to a single object. Hope this was helpful.


#4

just note : your title should be 11/30.