Javascript-Session 1-Objects

Retrieving a property from an object. Below the name and address properties are pulled from the designOffice object. First using a variable then using the objects path. Online link here.

<html>
<head>
<title>Objects</title>
</head>

<body>
<h1>Objects</h1>

<script language=”JavaScript”>

document.write(”<h2>Retrieving a property of an object</h2>”);

var designOffice = {name  : “Pentagram”,
address : 204 Fifth Avenue”,
city     : “New York”,
state    : “NY”,
zip : 10010
};
var list = designOffice.name;
document.write(’The value of the “name” property of the object ‘ + ‘designOffice’ + ‘ is: ‘ + list + ‘<br />’);
document.write(’The value of the “address” property is: ‘ + designOffice.address);

</script>
</body>







Leave a Reply

You must be logged in to post a comment.