Using the Book Object Constructor : Objects Object Oriented « Language Basics « JavaScript DHTML






Using the Book Object Constructor

 
<html>
<head>
  <title>Using the book object</title>
  <script type="text/javascript">
  <!--
  function book(title, author, ISBN, subject, rating) {
    this.title = title;
    this.author = author;
    this.ISBN = ISBN;
    this.subject = subject;
    this.rating = rating;
    this.show = show;
  }
   
  function show() {
    alert(this.title + this.author + this.ISBN + this.subject + this.rating );
  }
  //-->  </script>
</head>
<body>
  <script type="text/javascript">
  <!--
    dbBook = new book("Title", "Author","1-11111-111-1",  "Computer", 5);
    dbBook.show();
  //-->
  </script>
</body>
</html>



           
         
  








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.Creating Objects Dynamically
10.Object to array
11.Utility class for JavaScript class definition
12.Create an object and add attributes
13.Use for in loop to display all attributes from an object
14.Display the properties from an object one by one
15.An object and its constructor
16.Use function as the object constructor