Showing posts with label methods. Show all posts
Showing posts with label methods. Show all posts

Monday, 17 August 2015

Javascript Object Method

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 a Circle 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);

Javascript simple object image

Javascript Object

An object is a collection of properties. These properties can either be primitive data types, other objects, or functions (which in this case are called methods, but more on this later). A constructor function (or simply, constructor) is a function used to create an object – this too we’ll discuss in detail later. JavaScript comes with many built-in objects, such as the Array, Image, and Date objects. Many of you are familiar with Image objects from creating those ever-so-cute rollover effects. Well, when you use the code


var Image1 = new Image();  

Image1.src = "xyz.gif";

Make Object In javascript

function jobj(){
};

function jobj(){
    this.nm= 'an object';
    this.do = function(){
        alert('my name ' + this.nm);
    };
};

 

Subscribe to our Newsletter

Contact our Support

Email us: youremail@gmail.com

Our Team Memebers