Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

Create an Object with member method

< html> <head> <script language="Javascript" type = "text/javascript"> <!-- function employeeObj (name, address, phone, email) {     this.name = name;     this.address = address;     this.telephone = phone;     this.emailaddress = email;     this.printEmployee = printEmployee; } function printEmployee() {     document.write("employee Name:    " + this.name + "<br>\n");     document.write("Address:          " + this.address + "<br>\n");     document.write("Telephone Number: " + this.telephone + "<br>\n");     document.write("Email Address:    " + this.emailaddress); } var newEmployee = new employeeObj("AAA", "City, State", "555-555-5555", "aaa@website.com"); newEmployee.printEmployee(); //--> </script> </head> <body> </body> </html>