<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript constructor function</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();
</script>
</pre>
</body>
</html>