JavaScript OOP, MVC
What is Object Oriented Programming?
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
Javascript is Different from Most Other OOP
- There is no class in Javascript
- Every component in JavaScript is an Object, including Functions, Strings, and Numbers.
- Uses object literals or constructor functions to create objects
- Uses prototype inheritance
Function in Javascript
In Javascript, functions double as constructors. You call a function as a constructor by using the new operator.
Javascript Prototype
Advantage of using the prototype object to add functions
- No matter how many objects you create, functions are loaded only once into memory
- Allows you to override function if required
Encapsulation
- Concept: enclosing all the functionalities of an object within that object.
- Then we can instantiate an instance of User using User constructor.
Inheritance
In JavaScript, we don't have the concept of class, so inheritance in JavaScript is prototype based. This means to implement inheritance in JavaScript, an object inherits from another object.
Polymorphism
The ability to redefine methods for derived classes.
Homework
https://learn.javascript.ru/oop ООП в функциональном стиле
https://learn.javascript.ru/prototypes ООП в прототипном стиле
http://habrahabr.ru/post/144646 Понимание ООП в JavaScript
http://habrahabr.ru/post/144646 Javascript: ООП, прототипы, замыкания, «класс» Timer.js
http://tobyho.com/2010/11/22/javascript-constructors-and Javascript Constructors and Prototypes
https://raw.githubusercontent.com/coodict/javascript-in-one-pic/master/js%20in%20one%20pic.png All JavaScript ( taken from GitHub)
http://www.internet-technologies.ru/articles/article_2723.html Модель-Представление-Контроллер (MVC) с помощью JavaScript
Task
Can be found in the OneDrive folder
THANKS FOR YOUR ATTENTION
JAVASCRIPT OOP
JavaScript OOP, MVC
By Dima Pikulin
JavaScript OOP, MVC
- 1,581