Sunday, 15 July 2012
How to Create a template for an object using javascript
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function person(firstname,lastname,age,eyecolor)
{
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
}
myFather=new person("Peter","park",20,"black");
document.write(myFather.firstname + " is " + myFather.age + " years old.");
</script>
</body>
</html>
The result is:
Peter is 20 years old.
This post was written by: Bharathi
Bharthi is a professional blogger, web designer and front end web developer. Follow him on Twitter
Subscribe to:
Post Comments (Atom)
0 Responses to “How to Create a template for an object using javascript”
Post a Comment