• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 23. Cookies and Creating Your Ow... > Creating Custom Objects: Methods

Creating Custom Objects: Methods

To create a custom method, you just add it to an object as you would a property. Suppose, for example, that you wanted to add a method named display that displayed the person’s name in an alert box to a friend object; you could do that like this:

function friend(name, phone, rank) 
{ 
    this.name = name 
    this.phone = phone 
    this.rank = rank 
    this.display = display 
} 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint