Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html>
<head>
<script type="text/javascript">
<!--
// define basic object structure for a person, containing 2 strings and a date object
function personDetails(personName, personEmail, personDOB) {
this.name = personName;
this.email = personEmail;
this.DOB = personDOB;
}
// define object that will hold
var peopleDetails = { person:[], someOtherStuffMightGoHere: 123 };
// initialise data
peopleDetails.person[0] = new personDetails('Fred Bloggs', 'fred@bloggs.com', new Date('01/01/1964'));
peopleDetails.person[1] = new personDetails('Mike Raphone', 'mike@raphone.com', new Date('02/06/1968'));
peopleDetails.person[2] = new personDetails('Ray Zin', 'ray@zin.com', new Date('09/03/1972'));
var numPeople = peopleDetails.length;
for (var loop=0; loop<numPeople; loop++) {
}
// add a more powerful method than "toString" to an object
Object.prototype.toStringEnhanced = objToString;
function objToString() {
var s = '';
for (properties in this) {
var currentProperty = this[properties];
var propertyType = (typeof(currentProperty)).toLowerCase();
if (propertyType == 'function') {
// s += ' A function: ' + currentProperty + '\n'; // skip detail for methods. replace this line with "s += currentProperty;" to remove restriction
continue;
}
if (currentProperty.constructor == new Date().constructor) {
// for date objects, use default "toString()" method
s += properties + ': A date: ';
s += currentProperty;
s += '\n';
} else if (currentProperty.constructor == [].constructor) {
// for array objects, use different description
s += properties + ': An array:\n\n';
s += currentProperty.toStringEnhanced();
s += '\n';
} else if (propertyType == 'object') {
s += properties + ': ';
s += currentProperty.toStringEnhanced();
s += '\n';
} else {
s += properties + ': ';
s += currentProperty;
s += '\n';
}
}
return(s);
}
// show object detail with regular "toString()" method
alert(peopleDetails);
// show object detail with enhanced "toString()" method
alert(peopleDetails.toStringEnhanced());
//-->
</script>
</head>
<body>
</body>
</html>