G
Gene Wirchenko
Dear JavaScripters:
The following code is meant is extend an object definition. The
code works. My question is whether it works best. Is the way that I
have initialised the properties in Commercial that are from RealEstate
the best way to do it? I have a feeling that I might/should
initialise them using the RealEstate constructor, but I do not know
how to go about doing that.
1) How should I be doing it?
2) In the template statement, what does the new do? I have seen
code with it and without it. Both seem to work, but which way is
correct/better?
***** Start of Code *****
<html>
<head>
<title>try4.html</title>
</head>
<body>
<script type="text/javascript">
function RealEstate
(
PropertyLocation,
PropertyValue
)
{
this.PropertyLocation=PropertyLocation;
this.PropertyValue=PropertyValue;
}
function Commercial
(
PropertyLocation,
PropertyValue,
PropertyZoning,
PropertyUse
)
{
this.PropertyLocation=PropertyLocation;
this.PropertyValue=PropertyValue;
this.PropertyZoning=PropertyZoning;
this.PropertyUse=PropertyUse;
}
Commercial.template=new RealEstate();
var Prop1=new Commercial("Kamloops",150000,"C-1","light commercial");
document.write("Location: "+Prop1.PropertyLocation+"<br>");
document.write("Value: "+Prop1.PropertyValue+"<br>");
document.write("Zoning: "+Prop1.PropertyZoning+"<br>");
document.write("Use: "+Prop1.PropertyUse+"<br>");
</script>
</body>
</html>
***** End of Code *****
Sincerely,
Gene Wirchenko
The following code is meant is extend an object definition. The
code works. My question is whether it works best. Is the way that I
have initialised the properties in Commercial that are from RealEstate
the best way to do it? I have a feeling that I might/should
initialise them using the RealEstate constructor, but I do not know
how to go about doing that.
1) How should I be doing it?
2) In the template statement, what does the new do? I have seen
code with it and without it. Both seem to work, but which way is
correct/better?
***** Start of Code *****
<html>
<head>
<title>try4.html</title>
</head>
<body>
<script type="text/javascript">
function RealEstate
(
PropertyLocation,
PropertyValue
)
{
this.PropertyLocation=PropertyLocation;
this.PropertyValue=PropertyValue;
}
function Commercial
(
PropertyLocation,
PropertyValue,
PropertyZoning,
PropertyUse
)
{
this.PropertyLocation=PropertyLocation;
this.PropertyValue=PropertyValue;
this.PropertyZoning=PropertyZoning;
this.PropertyUse=PropertyUse;
}
Commercial.template=new RealEstate();
var Prop1=new Commercial("Kamloops",150000,"C-1","light commercial");
document.write("Location: "+Prop1.PropertyLocation+"<br>");
document.write("Value: "+Prop1.PropertyValue+"<br>");
document.write("Zoning: "+Prop1.PropertyZoning+"<br>");
document.write("Use: "+Prop1.PropertyUse+"<br>");
</script>
</body>
</html>
***** End of Code *****
Sincerely,
Gene Wirchenko