Object Methods
In addition to properties, objects can have methods. An object’s method is a function it can perform. Let’s take a look at this example. For this one, let’s create aCircle
object. First, we’re going to have to define our functions, and then make them methods of our Circle
object. Let’s define our Circle()
constructor and a Circle
object or two:function Circle(radius){
this.radius = radius;
}
var bigCircle = new Circle(100);
var smallCircle = new Circle(2);
0 comments:
Post a Comment