Use dojo to create class : Class Definition « Dojo toolkit « JavaScript Tutorial






<html>
  <head>
    <script type="text/javascript">
      var djConfig = {
        baseScriptUri : "js/dojo/"
      };
    </script>
    <script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
    <script>
      function FirstName() {
        var firstName = "A";
        this.getFirstName = function() {
          return firstName;
        }
      }
      function LastName() {
        var lastName = "F";
        this.getLastName = function() {
          return lastName;
        }
      }
      dojo.declare("com.java2s.AnotherClass", [ FirstName, LastName],
        { middleName : "W",
          getMiddleName : function() {
            return this.middleName;
           }
         }
       );
       var o = new com.java2s.AnotherClass();
       alert(o.getFirstName() + " " + o.getMiddleName() + " " + o.getLastName());

    </script>

  </head>

  <body></body>

</html>








29.44.Class Definition
29.44.1.Extend class
29.44.2.Use dojo to create class
29.44.3.Use package name in function definition