Create an Object with member method : Member Function « Object Oriented « JavaScript Tutorial






<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>








25.4.Member Function
25.4.1.Defining the object methods outside of the factory functions and then pointing to them
25.4.2.Create an Object with member method
25.4.3.Add member function
25.4.4.Adding method to a class using prototype
25.4.5.Custom objects and associative object arrays
25.4.6.Instance method
25.4.7.Call object member function