Object-Oriented Programming
1. What is Object-Oriented Programming
2. Class Module Pattern
Method Call
let counter1 = {
value: 0;
increase: function() {
this.value++ // When calling a method, this refers to counter1
},
decrease: function() {
this.value--
},
getValue: function() {
return this.value
}
}
counter1.increase()
counter1.decrease()
counter1.increase()
counter1.decrease()
counter1.getValue() // 2Creating New Objects Each Time Using Closure
3. Class and Instance
Syntax for Creating Classes: class keyword
Creating Class Instances
this: Instance Object
Method Definition
Summary
4. Object-Oriented Programming
Procedural Language > Object-Oriented Language
Four Basic Concepts of OOP
(1) Encapsulation
(2) Inheritance
(3) Abstraction
(4) Polymorphism
5. Prototype
Prototype and Class
Prototype Chain
Last updated