<html>
<head>
<title>Dynamic Prototype Pattern Example</title>
<script type="text/javascript">
function Person(name, age, job){
//properties
this.name = name;
this.age = age;
this.job = job;
//methods
if (typeof this.sayName != "function"){
Person.prototype.sayName = function(){
alert(this.name);
};
}
}
var friend = new Person("Nicholas", 29, "Software Engineer");
friend.sayName();
</script>
</head>
<body>
</body>
</html>