SlideShare a Scribd company logo
OOP IN JAVASCRIPT
Object-oriented programming concepts –
Advance JavaScript for Coders: Learn OOP
in JavaScript - A Course from Eduonix
IT ALL STARTS WITH AN "OBJECT"
 An object is a "thing": something that you use or interact with. For
example: a car
 It has properties (characteristics) and methods (capabilities):
 Properties: like color, model, price…etc.
 Methods: like move forward, reverse, gear-up/down, stop…etc.
 The object is the heart of object-oriented programming not only in
JavaScript only; but also in all OOP-aware languages like Java, C++
and others.
AN OBJECT COMES FROM A "CLASS"
 In order to make a new car, there must be some sort of a "blueprint" to
be used in the process.
 For example, a 4x4 Jeep manufacture process will differ than that of a
Mini-Cooper for example. There would be a different blueprint for each
of them.
 A class to an object is like a blueprint to make a car (or any other
product).
 You can make multiple objects from one class, all share the same
properties and methods.
 In JavaScript, a class is not defined as in other OOP languages.
JavaScript uses prototyping (discussed later)
ENCAPSULATION
 It refers to the ability of the object to execute its functionality without
revealing any execution detail to the caller.
 For example, you can use the gas pedal to make a car object move
forward. The specific mechanism that was used by the vehicle to
actually move is completely hidden from you, the driver (the caller).
 In other OOP languages, encapsulation may refer to "access levels".
An object may have an access level of public (everybody has access),
protected (less access than public), and private (much less access).
However, in JavaScript there are no access levels. Accordingly, other
techniques are used to achieve the same effect (discussed later).
OBJECT AGGREGATION
 Aggregation refers to the use of multiple small
objects to create a larger, more complex one.
 For example, a car is an object. But deep inside it
you can find hundreds of smaller, simpler objects
that – together – make up the car. Think of the
steering wheel, the gear box, the brakes, the tires
and so on…
INHERITANCE
 Alright, we have the blueprint to manufacture a generic car, but later
on we are requested to make a police car. It will have all the
properties and methods of a generic car (color, model, move,
stop…etc) plus some more specific ones. For example, it should have
a certain color (blue), the horn method will produce a siren and so on.
 Instead of re-creating a new car from scratch just to implelement
those changes, we could create a child object from the car object.
This child will inherit all the properties and methods of the parent one
(inheritance).
 The child object can not only add new properties and methods to the
ones it already inherits, but it can also change (override) those
originals. For example, the top speed property of a police car should
be higher than that of a normal car.
POLYMORPHISM
 The term "poly" means "many" while the term "morphism", from
"morph", means "change".
 Suppose you have a car1 object, and car2 object. Car1 is a police car,
and car2 is a sports car, but both of them inherit from the generic car
object. Accordingly, both of them implement a method horn(). You can
call the horn() method on any object of them, even if you have no idea
whether the object is a police car or a sports car, either of them will
execute its own implementation of the horn() method.
USING THE BROWSER'S CONSOLE
 The console is an excellent way to try out JavaScript code.
 In all major browsers (Chrome, Safari, Firefox, and Internet Explorer) it can be
activated by right clicking anywhere in a page and choose inspect element as
shown:
OTHER CONSOLES
 In Firefox (and lately in Chrome), you can install
firebug (firebug lite in Chrome), which would
provide a richer set of features than the built-in
developer tools that ship with the browser, and it
has its own console
Source Link:
https://www.eduonix.com/courses/Web-Development/advance-
javascript-for-coders-learn-oop-in-javascript
Thank Youwww.eduonix.com
Ad

More Related Content

Similar to Advance Javascript for Coders (20)

2 oop
2 oop2 oop
2 oop
Ali Baba
 
OOP in C# Classes and Objects.
OOP in C# Classes and Objects.OOP in C# Classes and Objects.
OOP in C# Classes and Objects.
Abid Kohistani
 
Java oop concepts
Java oop conceptsJava oop concepts
Java oop concepts
Syeful Islam
 
Object Oriented Programing and JAVA
Object Oriented Programing and JAVAObject Oriented Programing and JAVA
Object Oriented Programing and JAVA
Gujarat Technological University
 
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdfII BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
rajeswaria21
 
A350103
A350103A350103
A350103
aijbm
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
Self
 
1 intro
1 intro1 intro
1 intro
abha48
 
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Java Object-Oriented Programming Conecpts(Real-Time) ExamplesJava Object-Oriented Programming Conecpts(Real-Time) Examples
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Shridhar Ramesh
 
Java
JavaJava
Java
Shridhar Ramesh
 
Design patterns
Design patternsDesign patterns
Design patterns
nisheesh
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx
ssusercae49e
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
talha ijaz
 
object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)
munibali55
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
Togakangaroo
 
Angular js mobile jsday 2014 - Verona 14 may
Angular js mobile   jsday 2014 - Verona 14 mayAngular js mobile   jsday 2014 - Verona 14 may
Angular js mobile jsday 2014 - Verona 14 may
Luciano Amodio
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
Rich Helton
 
Java getstarted
Java getstartedJava getstarted
Java getstarted
Nobin নবীন
 
OOP in C# Classes and Objects.
OOP in C# Classes and Objects.OOP in C# Classes and Objects.
OOP in C# Classes and Objects.
Abid Kohistani
 
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdfII BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
rajeswaria21
 
A350103
A350103A350103
A350103
aijbm
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
Self
 
1 intro
1 intro1 intro
1 intro
abha48
 
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Java Object-Oriented Programming Conecpts(Real-Time) ExamplesJava Object-Oriented Programming Conecpts(Real-Time) Examples
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Shridhar Ramesh
 
Design patterns
Design patternsDesign patterns
Design patterns
nisheesh
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx
ssusercae49e
 
object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)
munibali55
 
Angular js mobile jsday 2014 - Verona 14 may
Angular js mobile   jsday 2014 - Verona 14 mayAngular js mobile   jsday 2014 - Verona 14 may
Angular js mobile jsday 2014 - Verona 14 may
Luciano Amodio
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
Rich Helton
 

More from Paddy Lock (13)

An Inforgraphic to Learn React Native
An Inforgraphic to Learn React NativeAn Inforgraphic to Learn React Native
An Inforgraphic to Learn React Native
Paddy Lock
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
Paddy Lock
 
Docker for Professionals: The Practical Guide
Docker for Professionals: The Practical GuideDocker for Professionals: The Practical Guide
Docker for Professionals: The Practical Guide
Paddy Lock
 
Getting started with React and Redux
Getting started with React and ReduxGetting started with React and Redux
Getting started with React and Redux
Paddy Lock
 
Beginners Guide to Modeling with Maya
Beginners Guide to Modeling with MayaBeginners Guide to Modeling with Maya
Beginners Guide to Modeling with Maya
Paddy Lock
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Paddy Lock
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development Tutorial
Paddy Lock
 
PPT on Photoshop
PPT on PhotoshopPPT on Photoshop
PPT on Photoshop
Paddy Lock
 
A Complete Guide For Effective Business Communication – A Course from Eduonix
A Complete Guide For Effective  Business Communication – A Course from EduonixA Complete Guide For Effective  Business Communication – A Course from Eduonix
A Complete Guide For Effective Business Communication – A Course from Eduonix
Paddy Lock
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
Paddy Lock
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
Paddy Lock
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming Language
Paddy Lock
 
Presentation on Eduonix
 Presentation on Eduonix Presentation on Eduonix
Presentation on Eduonix
Paddy Lock
 
An Inforgraphic to Learn React Native
An Inforgraphic to Learn React NativeAn Inforgraphic to Learn React Native
An Inforgraphic to Learn React Native
Paddy Lock
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
Paddy Lock
 
Docker for Professionals: The Practical Guide
Docker for Professionals: The Practical GuideDocker for Professionals: The Practical Guide
Docker for Professionals: The Practical Guide
Paddy Lock
 
Getting started with React and Redux
Getting started with React and ReduxGetting started with React and Redux
Getting started with React and Redux
Paddy Lock
 
Beginners Guide to Modeling with Maya
Beginners Guide to Modeling with MayaBeginners Guide to Modeling with Maya
Beginners Guide to Modeling with Maya
Paddy Lock
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Paddy Lock
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development Tutorial
Paddy Lock
 
PPT on Photoshop
PPT on PhotoshopPPT on Photoshop
PPT on Photoshop
Paddy Lock
 
A Complete Guide For Effective Business Communication – A Course from Eduonix
A Complete Guide For Effective  Business Communication – A Course from EduonixA Complete Guide For Effective  Business Communication – A Course from Eduonix
A Complete Guide For Effective Business Communication – A Course from Eduonix
Paddy Lock
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
Paddy Lock
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
Paddy Lock
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming Language
Paddy Lock
 
Presentation on Eduonix
 Presentation on Eduonix Presentation on Eduonix
Presentation on Eduonix
Paddy Lock
 
Ad

Recently uploaded (20)

Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Debunking the Myths behind AI - v1, Carl Dalby
Debunking the Myths behind AI -  v1, Carl DalbyDebunking the Myths behind AI -  v1, Carl Dalby
Debunking the Myths behind AI - v1, Carl Dalby
Association for Project Management
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Sugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptxSugar-Sensing Mechanism in plants....pptx
Sugar-Sensing Mechanism in plants....pptx
Dr. Renu Jangid
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Ad

Advance Javascript for Coders

  • 1. OOP IN JAVASCRIPT Object-oriented programming concepts – Advance JavaScript for Coders: Learn OOP in JavaScript - A Course from Eduonix
  • 2. IT ALL STARTS WITH AN "OBJECT"  An object is a "thing": something that you use or interact with. For example: a car  It has properties (characteristics) and methods (capabilities):  Properties: like color, model, price…etc.  Methods: like move forward, reverse, gear-up/down, stop…etc.  The object is the heart of object-oriented programming not only in JavaScript only; but also in all OOP-aware languages like Java, C++ and others.
  • 3. AN OBJECT COMES FROM A "CLASS"  In order to make a new car, there must be some sort of a "blueprint" to be used in the process.  For example, a 4x4 Jeep manufacture process will differ than that of a Mini-Cooper for example. There would be a different blueprint for each of them.  A class to an object is like a blueprint to make a car (or any other product).  You can make multiple objects from one class, all share the same properties and methods.  In JavaScript, a class is not defined as in other OOP languages. JavaScript uses prototyping (discussed later)
  • 4. ENCAPSULATION  It refers to the ability of the object to execute its functionality without revealing any execution detail to the caller.  For example, you can use the gas pedal to make a car object move forward. The specific mechanism that was used by the vehicle to actually move is completely hidden from you, the driver (the caller).  In other OOP languages, encapsulation may refer to "access levels". An object may have an access level of public (everybody has access), protected (less access than public), and private (much less access). However, in JavaScript there are no access levels. Accordingly, other techniques are used to achieve the same effect (discussed later).
  • 5. OBJECT AGGREGATION  Aggregation refers to the use of multiple small objects to create a larger, more complex one.  For example, a car is an object. But deep inside it you can find hundreds of smaller, simpler objects that – together – make up the car. Think of the steering wheel, the gear box, the brakes, the tires and so on…
  • 6. INHERITANCE  Alright, we have the blueprint to manufacture a generic car, but later on we are requested to make a police car. It will have all the properties and methods of a generic car (color, model, move, stop…etc) plus some more specific ones. For example, it should have a certain color (blue), the horn method will produce a siren and so on.  Instead of re-creating a new car from scratch just to implelement those changes, we could create a child object from the car object. This child will inherit all the properties and methods of the parent one (inheritance).  The child object can not only add new properties and methods to the ones it already inherits, but it can also change (override) those originals. For example, the top speed property of a police car should be higher than that of a normal car.
  • 7. POLYMORPHISM  The term "poly" means "many" while the term "morphism", from "morph", means "change".  Suppose you have a car1 object, and car2 object. Car1 is a police car, and car2 is a sports car, but both of them inherit from the generic car object. Accordingly, both of them implement a method horn(). You can call the horn() method on any object of them, even if you have no idea whether the object is a police car or a sports car, either of them will execute its own implementation of the horn() method.
  • 8. USING THE BROWSER'S CONSOLE  The console is an excellent way to try out JavaScript code.  In all major browsers (Chrome, Safari, Firefox, and Internet Explorer) it can be activated by right clicking anywhere in a page and choose inspect element as shown:
  • 9. OTHER CONSOLES  In Firefox (and lately in Chrome), you can install firebug (firebug lite in Chrome), which would provide a richer set of features than the built-in developer tools that ship with the browser, and it has its own console