Professional Documents
Culture Documents
Object-Oriented Programming
JavaScript Group
Department of Information Technology Supporting and Maintenance
University General
of Computer
lecture Plan Studies
• Section 1
What is JavaScript? • Section 4
JavaScript in HTML Document Object Model(DOM) and
DOM Extensions
Variables, Scope, and Memory
• Section 5
• Section 2
Events, Forms and Canvas
Language Basics
• Section 6
Reference Types
Client-side Storage
• Section 3
Understanding Objects
Window Object
Object
University Creation Studies
of Computer
• Factory Pattern
• Parasitic Constructor Pattern
• Constructor Pattern
• Prototype Pattern
• Combination Constructor + Prototype Pattern
• Dynamic Prototype
• Durable Constructor pattern
1. Factory
University PatternStudies
of Computer
function Person(){ }
Person.prototype.name = "Nicholas";
Person.prototype.age = 29;
Person.prototype.job = "Software Engineer";
Person.prototype.sayName = function(){ alert(this.name); };
var person1 = new Person();
person1.sayName(); //"Nicholas"
var person2 = new Person();
person2.sayName(); //"Nicholas"
5. Combination Constructor
University + Prototype
of Computer Studies Pattern
Exercise
• Create an object named Person with properties(name, age, job) and a method
named sayName which return the name of object with alert. Create an instance of
object with "Nicholas", 29,"Software Engineer". Call the method of object.
(Parasitic Constructor Pattern)
Reference
University Book Studies
of Computer
• Function Expressions
University of Computer Studies
Thank you!