Class combination with constructor : Combination : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Combination »

 

Class combination with constructor

















<html>
<head>
<script language="Javascript" type = "text/javascript">
<!--
function companyObj (cname, caddress, cphone) {
    this.cname = cname;
    this.caddress = caddress;
    this.ctelephone = cphone;
}
var newComp = new companyObj("ABC""City, State""555-555-5555");

function EmployeeObj (name, address, phone, email,newComp) {
    this.name = name;
    this.address = address;
    this.telephone = phone;
    this.emailaddress = email;
    this.compObj = newComp;
}
var newCust = new EmployeeObj("J S""City, State""555-555-5555","j@s.com", newComp);

document.write("Employee Name:    " + newCust.name + "<br>n");
document.write("Address:          " + newCust.address + "<br>n");
document.write("Telephone Number: " + newCust.telephone + "<br>n");
document.write("Email Address:    " + newCust.emailaddress + "<br>n");
document.write("Company Name:     " + newCust.compObj.cname + "<br>n");
document.write("Company Address:  " + newCust.compObj.caddress + "<br>n");
document.write("Telephone Number: " + newCust.compObj.ctelephone);
//-->
</script>
</head>
<body>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Combination