<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript constructor function add method</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script type="text/javascript">
var Foo = function Foo(name) {
this.name = name;
this.position = function() {
document.writeln("Hi, I'm " + this.name + ", My discipline is Sales Account Manager.");
}
}
var foo = new Foo("Opal Kole");
foo.position();
Foo.prototype.rename = function(name) {
this.name = name;
}
foo.rename("Max Miller");
foo.position();
</script>
</pre>
</body>
</html>