Wednesday, December 20, 2017

Objects




Object is a piece of data with its own properties and methods.

Below is an example:

<head>
<script type =”text/javascript”>
function person (name, age)
{
this.name = name;
this.age = age;
}
Var anastasia =  new person(“Anastasia”, 25);
Var grisham =  new person(“Grisham”, 25);
</script>
</head>
<body>
<script type =”text/javascript”>
document.write(anastasia.name);
</script>
</body>