SlideShare a Scribd company logo
3
OBJECT ORIENTED PROGRAMMING
 Object Oriented Programming – A programming paradigm where we use Objects to model real
world things.
 Object – Collection of related data and/or functionality. (Encapsulation)
 Variables and Functions — are called properties and methods when they are inside objects.
Most read
4
OBJECTS IN JAVASCRIPT
 Ways of creating an Object in JavaScript
1. var myObj1 = { };
2. var myObj2 = new Object();
3. var myObj3 = function () { var obj = {}; return obj;};
4. function MyObj4() { this.myVar = ‘’; };
 The constructor function is JavaScript's version of a class. (No: 4)
 A constructor function name usually starts with a capital letter — this convention is used to make
constructor functions easier to recognize in code.
Most read
6
ACCESS OBJECT PROPERTIES
 Dot Notation
 person.age, person.gender
 Person.name.first, person.name.last
 Bracket Notation
 Using Property:
 person[‘age’], person[‘gender’]
 person[‘name’][‘first’], person[‘name’][‘last’]
 Using Index:
 person[0], person[1]
 Person[0][‘first’], Person[0].first
 Difference
 Dot notation can only accept a literal member name, not a variable value pointing to a name
Most read
OBJECT ORIENTED PROGRAMMING
IN
JAVASCRIPT
(OOJS)
-- Aditya Majety
FreeCodeCamp Lightning Talk
14-Mar-2017
AGENDA
 Object Oriented Programming
 Objects in JavaScript
 Access Object Properties
 Set Object Properties
 ‘this’ keyword
 Prototypes
 Prototypal Inheritance
 ECMAScript6
OBJECT ORIENTED PROGRAMMING
 Object Oriented Programming – A programming paradigm where we use Objects to model real
world things.
 Object – Collection of related data and/or functionality. (Encapsulation)
 Variables and Functions — are called properties and methods when they are inside objects.
OBJECTS IN JAVASCRIPT
 Ways of creating an Object in JavaScript
1. var myObj1 = { };
2. var myObj2 = new Object();
3. var myObj3 = function () { var obj = {}; return obj;};
4. function MyObj4() { this.myVar = ‘’; };
 The constructor function is JavaScript's version of a class. (No: 4)
 A constructor function name usually starts with a capital letter — this convention is used to make
constructor functions easier to recognize in code.
OBJECTS IN JAVASCRIPT (CONTD..)
Object Format
var objectName = {
member1Name: member1Value,
member2Name: member2Value,
member3Name: member3Value
}
 Each name/value pair must be
separated by a comma
 The name and value in each case are
separated by a colon
Sample Object
var person = {
name : {
first: 'Bob',
last: 'Smith‘
},
age: 32,
gender: 'male',
greeting: function() {
alert('Hi! I am ' + this.name[0]);
}
};
ACCESS OBJECT PROPERTIES
 Dot Notation
 person.age, person.gender
 Person.name.first, person.name.last
 Bracket Notation
 Using Property:
 person[‘age’], person[‘gender’]
 person[‘name’][‘first’], person[‘name’][‘last’]
 Using Index:
 person[0], person[1]
 Person[0][‘first’], Person[0].first
 Difference
 Dot notation can only accept a literal member name, not a variable value pointing to a name
SET OBJECT PROPERTIES
 person.age = 45
 person['name']['last'] = 'Cratchit‘
 We can also create new members.
 person['eyes'] = 'hazel'
 person.farewell = function() { alert("Bye everybody!") }
‘THIS’ KEYWORD
 The this keyword refers to the current object
the code is being written inside.
 Eg. Two different person object instances
may have different names, but will want to
use their own name when saying their
greeting.
 Person1.greeting() -> ‘Hi I’m Chris’
 Person2.greeting() -> ‘Hi I’m Brian’
PROTOTYPE
 We have to understand Prototypes to understand Inheritance.
 Each object has a prototype object, which acts as a template object that it inherits methods and properties
from.
 Prototypes are the mechanism by which JavaScript objects inherit features from one another.
 Prototype Chain : An object's prototype object may also have a prototype object, which it inherits methods
and properties from, and so on
 In classic OOP, classes are defined, then when object instances are created all the properties and methods
defined on the class are copied over to the instance.
 In JavaScript, they are not copied over — instead, a link is made between the object instance and its
constructor (a link in the prototype chain), and the properties and methods are found in the constructor by
walking up the chain.
PROTOTYPAL INHERITANCE
 How do we create an Object in JavaScript that inherits from another Object? (other than built-in
Objects)
 Only Constructors have prototype property. Object instances do not have it.
 Steps to Inherit from another Object
 Create the Main constructor
 Create the Child constructor
 Set Prototype
 Set Constructor Reference
PROTOTYPAL INHERITANCE CONTD..
Step 1
Step 2
Step 3
Step 4
ECMASCRIPT6
Equal to Constructor Function Create a Sub Class
THANK YOU

More Related Content

What's hot (20)

Ruby object model
Ruby object modelRuby object model
Ruby object model
Chamnap Chhorn
 
Only oop
Only oopOnly oop
Only oop
anitarooge
 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
Mutinda Boniface
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
Hazem Hagrass
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
Dhananjay Kumar
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
Dhivyashree Selvarajtnkpm
 
Hibernate
HibernateHibernate
Hibernate
Harish Patil ( ハリシュパテイル)
 
OOP, API Design and MVP
OOP, API Design and MVPOOP, API Design and MVP
OOP, API Design and MVP
Harshith Keni
 
Object oriented programming in php
Object oriented programming in phpObject oriented programming in php
Object oriented programming in php
Aashiq Kuchey
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
Michael Peacock
 
Introduction to javascript and yoolkui
Introduction to javascript and yoolkuiIntroduction to javascript and yoolkui
Introduction to javascript and yoolkui
Khou Suylong
 
Solid OOPS
Solid OOPSSolid OOPS
Solid OOPS
Toshish Jawale
 
Javascript closures
Javascript closures Javascript closures
Javascript closures
VNG
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
Dot Com Infoway - Custom Software, Mobile, Web Application Development and Digital Marketing Company
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Ruby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for rubyRuby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for ruby
Tushar Pal
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
InnovationM
 
Metaprogramming in JavaScript
Metaprogramming in JavaScriptMetaprogramming in JavaScript
Metaprogramming in JavaScript
Mehdi Valikhani
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
Dhananjay Kumar
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
Dhivyashree Selvarajtnkpm
 
OOP, API Design and MVP
OOP, API Design and MVPOOP, API Design and MVP
OOP, API Design and MVP
Harshith Keni
 
Object oriented programming in php
Object oriented programming in phpObject oriented programming in php
Object oriented programming in php
Aashiq Kuchey
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
CPD INDIA
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
Michael Peacock
 
Introduction to javascript and yoolkui
Introduction to javascript and yoolkuiIntroduction to javascript and yoolkui
Introduction to javascript and yoolkui
Khou Suylong
 
Javascript closures
Javascript closures Javascript closures
Javascript closures
VNG
 
Synapseindia object oriented programming in php
Synapseindia object oriented programming in phpSynapseindia object oriented programming in php
Synapseindia object oriented programming in php
Synapseindiappsdevelopment
 
Ruby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for rubyRuby object model - Understanding of object play role for ruby
Ruby object model - Understanding of object play role for ruby
Tushar Pal
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
InnovationM
 
Metaprogramming in JavaScript
Metaprogramming in JavaScriptMetaprogramming in JavaScript
Metaprogramming in JavaScript
Mehdi Valikhani
 

Viewers also liked (19)

OCAJP_SE8_eCertificate
OCAJP_SE8_eCertificateOCAJP_SE8_eCertificate
OCAJP_SE8_eCertificate
Aditya Majety
 
Equity bazaar 14032017
Equity bazaar 14032017Equity bazaar 14032017
Equity bazaar 14032017
choice broking
 
План роботи РМО вчителів інформатики
План роботи РМО вчителів інформатикиПлан роботи РМО вчителів інформатики
План роботи РМО вчителів інформатики
RMO Hayvoron
 
Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Church Youth Work - (Gloria, Dembo, Lisa, Ola)Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Early Artis
 
JavaScript im Jahr 2016
JavaScript im Jahr 2016JavaScript im Jahr 2016
JavaScript im Jahr 2016
Christian Kaltepoth
 
Encapsulation in JavaScript - OOP
Encapsulation in JavaScript - OOPEncapsulation in JavaScript - OOP
Encapsulation in JavaScript - OOP
Aditya Majety
 
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
IJSRD
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
Mike Wilcox
 
거버넌스 혹은 협치?!
거버넌스 혹은 협치?!거버넌스 혹은 협치?!
거버넌스 혹은 협치?!
ya rigury
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
T11 Sessions
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
Mindy McAdams
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming language
Marco Cedaro
 
Reactive Programming with JavaScript
Reactive Programming with JavaScriptReactive Programming with JavaScript
Reactive Programming with JavaScript
Codemotion
 
Javascript Tutorial
Javascript TutorialJavascript Tutorial
Javascript Tutorial
Kang-min Liu
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
hindi news
hindi newshindi news
hindi news
Breaking News of India
 
Introduction to JavaScript Programming
Introduction to JavaScript ProgrammingIntroduction to JavaScript Programming
Introduction to JavaScript Programming
Collaboration Technologies
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
Troy Miles
 
OCAJP_SE8_eCertificate
OCAJP_SE8_eCertificateOCAJP_SE8_eCertificate
OCAJP_SE8_eCertificate
Aditya Majety
 
Equity bazaar 14032017
Equity bazaar 14032017Equity bazaar 14032017
Equity bazaar 14032017
choice broking
 
План роботи РМО вчителів інформатики
План роботи РМО вчителів інформатикиПлан роботи РМО вчителів інформатики
План роботи РМО вчителів інформатики
RMO Hayvoron
 
Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Church Youth Work - (Gloria, Dembo, Lisa, Ola)Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Church Youth Work - (Gloria, Dembo, Lisa, Ola)
Early Artis
 
Encapsulation in JavaScript - OOP
Encapsulation in JavaScript - OOPEncapsulation in JavaScript - OOP
Encapsulation in JavaScript - OOP
Aditya Majety
 
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
IJSRD
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
Mike Wilcox
 
거버넌스 혹은 협치?!
거버넌스 혹은 협치?!거버넌스 혹은 협치?!
거버넌스 혹은 협치?!
ya rigury
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
T11 Sessions
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming language
Marco Cedaro
 
Reactive Programming with JavaScript
Reactive Programming with JavaScriptReactive Programming with JavaScript
Reactive Programming with JavaScript
Codemotion
 
Javascript Tutorial
Javascript TutorialJavascript Tutorial
Javascript Tutorial
Kang-min Liu
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
Sauce Labs
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
Troy Miles
 
Ad

Similar to Object oriented programming in JavaScript (20)

Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptx
MariaTrinidadTumanga
 
IWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptxIWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
Object Oriented Javascript part2
Object Oriented Javascript part2Object Oriented Javascript part2
Object Oriented Javascript part2
Usman Mehmood
 
Javascript Object Oriented Programming
Javascript Object Oriented ProgrammingJavascript Object Oriented Programming
Javascript Object Oriented Programming
Bunlong Van
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
Thennarasan Shanmugam
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
Shah Jalal
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2
Thang Tran Duc
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
HDR1001
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
Stoyan Stefanov
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
Jscript part2
Jscript part2Jscript part2
Jscript part2
Girish Srivastava
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big Picture
Manish Jangir
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
Jussi Pohjolainen
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02
plutoone TestTwo
 
JavaScript Essentials
JavaScript EssentialsJavaScript Essentials
JavaScript Essentials
Triphon Statkov
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
David Atchley
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
msneha
 
Function-and-prototype defined classes in JavaScript
Function-and-prototype defined classes in JavaScriptFunction-and-prototype defined classes in JavaScript
Function-and-prototype defined classes in JavaScript
Hong Langford
 
Understanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptxUnderstanding-Objects-in-Javascript.pptx
Understanding-Objects-in-Javascript.pptx
MariaTrinidadTumanga
 
IWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptxIWT presentation121232112122222225556+556.pptx
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
Object Oriented Javascript part2
Object Oriented Javascript part2Object Oriented Javascript part2
Object Oriented Javascript part2
Usman Mehmood
 
Javascript Object Oriented Programming
Javascript Object Oriented ProgrammingJavascript Object Oriented Programming
Javascript Object Oriented Programming
Bunlong Van
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
Shah Jalal
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2
Thang Tran Duc
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
HDR1001
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
Stoyan Stefanov
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big Picture
Manish Jangir
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02
plutoone TestTwo
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
msneha
 
Function-and-prototype defined classes in JavaScript
Function-and-prototype defined classes in JavaScriptFunction-and-prototype defined classes in JavaScript
Function-and-prototype defined classes in JavaScript
Hong Langford
 
Ad

Recently uploaded (20)

AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | BluebashMCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
MCP vs A2A vs ACP: Choosing the Right Protocol | Bluebash
Bluebash
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 

Object oriented programming in JavaScript

  • 1. OBJECT ORIENTED PROGRAMMING IN JAVASCRIPT (OOJS) -- Aditya Majety FreeCodeCamp Lightning Talk 14-Mar-2017
  • 2. AGENDA  Object Oriented Programming  Objects in JavaScript  Access Object Properties  Set Object Properties  ‘this’ keyword  Prototypes  Prototypal Inheritance  ECMAScript6
  • 3. OBJECT ORIENTED PROGRAMMING  Object Oriented Programming – A programming paradigm where we use Objects to model real world things.  Object – Collection of related data and/or functionality. (Encapsulation)  Variables and Functions — are called properties and methods when they are inside objects.
  • 4. OBJECTS IN JAVASCRIPT  Ways of creating an Object in JavaScript 1. var myObj1 = { }; 2. var myObj2 = new Object(); 3. var myObj3 = function () { var obj = {}; return obj;}; 4. function MyObj4() { this.myVar = ‘’; };  The constructor function is JavaScript's version of a class. (No: 4)  A constructor function name usually starts with a capital letter — this convention is used to make constructor functions easier to recognize in code.
  • 5. OBJECTS IN JAVASCRIPT (CONTD..) Object Format var objectName = { member1Name: member1Value, member2Name: member2Value, member3Name: member3Value }  Each name/value pair must be separated by a comma  The name and value in each case are separated by a colon Sample Object var person = { name : { first: 'Bob', last: 'Smith‘ }, age: 32, gender: 'male', greeting: function() { alert('Hi! I am ' + this.name[0]); } };
  • 6. ACCESS OBJECT PROPERTIES  Dot Notation  person.age, person.gender  Person.name.first, person.name.last  Bracket Notation  Using Property:  person[‘age’], person[‘gender’]  person[‘name’][‘first’], person[‘name’][‘last’]  Using Index:  person[0], person[1]  Person[0][‘first’], Person[0].first  Difference  Dot notation can only accept a literal member name, not a variable value pointing to a name
  • 7. SET OBJECT PROPERTIES  person.age = 45  person['name']['last'] = 'Cratchit‘  We can also create new members.  person['eyes'] = 'hazel'  person.farewell = function() { alert("Bye everybody!") }
  • 8. ‘THIS’ KEYWORD  The this keyword refers to the current object the code is being written inside.  Eg. Two different person object instances may have different names, but will want to use their own name when saying their greeting.  Person1.greeting() -> ‘Hi I’m Chris’  Person2.greeting() -> ‘Hi I’m Brian’
  • 9. PROTOTYPE  We have to understand Prototypes to understand Inheritance.  Each object has a prototype object, which acts as a template object that it inherits methods and properties from.  Prototypes are the mechanism by which JavaScript objects inherit features from one another.  Prototype Chain : An object's prototype object may also have a prototype object, which it inherits methods and properties from, and so on  In classic OOP, classes are defined, then when object instances are created all the properties and methods defined on the class are copied over to the instance.  In JavaScript, they are not copied over — instead, a link is made between the object instance and its constructor (a link in the prototype chain), and the properties and methods are found in the constructor by walking up the chain.
  • 10. PROTOTYPAL INHERITANCE  How do we create an Object in JavaScript that inherits from another Object? (other than built-in Objects)  Only Constructors have prototype property. Object instances do not have it.  Steps to Inherit from another Object  Create the Main constructor  Create the Child constructor  Set Prototype  Set Constructor Reference
  • 11. PROTOTYPAL INHERITANCE CONTD.. Step 1 Step 2 Step 3 Step 4
  • 12. ECMASCRIPT6 Equal to Constructor Function Create a Sub Class