Use function as the object constructor : Objects Object Oriented « Language Basics « JavaScript DHTML






Use function as the object constructor

 

<head>
<title></title>
</script>
</head>
<body>
<script type = "text/javascript" >

function Song(artist,length,title) {
    this.artist = artist;
    this.length = length;
    this.title = title;
}

song1 = new Song("A","3:30","title");

</script>
<p>Songs</p>
</body>

   
  








Related examples in the same category

1.Object utility: create, parse and profile
2.Define Object, use its instance
3.Define and use object
4. Creating an Object and Using Object Instance Properties and Methods
5. Object-Oriented Planetary Data Presentation
6.The Book Object Definition
7.Complete Example of Using the employee, client, and project Objects
8.Source Code for the showBook() Example
9.Using the Book Object Constructor
10.Creating Objects Dynamically
11.Object to array
12.Utility class for JavaScript class definition
13.Create an object and add attributes
14.Use for in loop to display all attributes from an object
15.Display the properties from an object one by one
16.An object and its constructor