SlideShare a Scribd company logo
OOP in JavaScript “ The World's Most Misunderstood Programming Language” Douglas Crockford
Some Myths JavaScript is related to Java JavaScript was developed by Sun Microsystems JavaScript is not Object Oriented JavaScript does not support data hiding, i.e. everything is public
OOP Concepts Encapsulation Inheritance Polymorphism
Encapsulation Definition Data + Operation Single logically organized unit Data visibility
Inheritance Definition Parent-child relationship between classes Child inherits Parents’ characteristics Child can redefine existing characteristics Child can add more characteristics
Polymorphism Definition Multiple functions Share a common name Context specific invocation The characteristic of being able to assign a different meaning or usage to something in different contexts  ( http://searchsmb.techtarget.com/sDefinition/0,,sid44_gci212803,00.html )
Encapsulation Private variables -  Can only be accessed by private functions and privileged methods Private functions -  Can only be called by privileged methods Privileged methods -  May invoked by code external to the object Public properties -  May be read/written from outside the object Public methods -  Shared methods Prototype properties -  Shared properties
Encapsulation function Student(name) { var age = 0; var checkAge = function(){ return (age > 0) ? age : false; }; this.getAge = function(){  return (checkAge()) ? age : “Age not set”;  } this.setAge = function(_age){ age = _age; } this.name = name; this.constructor.prototype.updateTotal(); } Student.prototype.total = 0; Student.prototype.updateTotal = function(){ this.constructor.prototype.total++; }
Inheritance See Listing 1 See Listing 2
Polymorphism See Listing 1
What more? JSON Closures
JSON Object  – { } Array  – [ ] Separator  –  , : Var students = [ {name :  “abc” ,  age :  20} , {name :  “xyz” ,  age :  21} ];
References http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference http://mckoss.com/jscript/object.htm http://www.sitepoint.com/article/oriented-programming-1 http://www.codeproject.com/aspnet/JsOOP1.asp http://phrogz.net/JS/Classes/OOPinJS.html http://javascript.crockford.com/javascript.html http://kevlindev.com/tutorials/javascript/inheritance/index.htm http://www.dustindiaz.com/javascript-private-public-privileged/ http://developer.yahoo.com/yui/theater/ http://www.dustindiaz.com/json-for-the-masses/ http:// www.json.org / Google + Wikipedia = Many Many more references

More Related Content

PPTX
Object Oriented JavaScript - II
PPTX
Object Oriented Programming In JavaScript
ODP
Object Oriented Javascript
PDF
JavaScript OOPs
PPTX
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
PDF
Object Oriented Programming in JavaScript
PPTX
JavaScript in Object-Oriented Way
KEY
Object Oriented JavaScript - II
Object Oriented Programming In JavaScript
Object Oriented Javascript
JavaScript OOPs
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Object Oriented Programming in JavaScript
JavaScript in Object-Oriented Way

What's hot (20)

PDF
JavaScript - Chapter 8 - Objects
PDF
Performance Optimization and JavaScript Best Practices
PPTX
Lecture 6: Client Side Programming 2
PPTX
Lecture 5: Client Side Programming 1
PPTX
Lecture 5 javascript
PPT
Prototype Js
PPTX
Javascript basics for automation testing
PPTX
JavaScript Basics - GameCraft Training
PDF
Advanced JavaScript - Internship Presentation - Week6
PPT
JavaScript Misunderstood
PPTX
JavaScript Fundamentals & JQuery
PPTX
Introduction to JavaScript Programming
KEY
Object oriented javascript
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
PDF
JavaScript 101
PDF
Paris Web - Javascript as a programming language
PPTX
Java script
PPTX
Introduction to JavaScrtipt
PDF
JavaScript Good Practices
JavaScript - Chapter 8 - Objects
Performance Optimization and JavaScript Best Practices
Lecture 6: Client Side Programming 2
Lecture 5: Client Side Programming 1
Lecture 5 javascript
Prototype Js
Javascript basics for automation testing
JavaScript Basics - GameCraft Training
Advanced JavaScript - Internship Presentation - Week6
JavaScript Misunderstood
JavaScript Fundamentals & JQuery
Introduction to JavaScript Programming
Object oriented javascript
Intro to node.js - Ran Mizrahi (28/8/14)
JavaScript 101
Paris Web - Javascript as a programming language
Java script
Introduction to JavaScrtipt
JavaScript Good Practices
Ad

Viewers also liked (20)

PDF
Data communication computer_network_tutorial
PPT
The Theory Of The Dom
PPT
Ajax Performance
PDF
Performance, Games, and Distributed Testing in JavaScript
KEY
Douglas Crockford - Programming Style and Your Brain
PPT
The JSON Saga
PDF
Performance Improvements in Browsers
PPT
Douglas Crockford - Ajax Security
PDF
Building a JavaScript Library
PPT
PDF
Good Parts of JavaScript Douglas Crockford
PPT
Advanced Javascript
PPTX
Advanced JavaScript Concepts
PPTX
Computer communication and networks
PPT
Object oriented programming (oop) cs304 power point slides lecture 01
PPT
Object-oriented concepts
PPSX
Data communication - Lecture-01
PDF
Scalable JavaScript Application Architecture
PPT
Linux Administration
PDF
CBSE XII Communication And Network Concepts
Data communication computer_network_tutorial
The Theory Of The Dom
Ajax Performance
Performance, Games, and Distributed Testing in JavaScript
Douglas Crockford - Programming Style and Your Brain
The JSON Saga
Performance Improvements in Browsers
Douglas Crockford - Ajax Security
Building a JavaScript Library
Good Parts of JavaScript Douglas Crockford
Advanced Javascript
Advanced JavaScript Concepts
Computer communication and networks
Object oriented programming (oop) cs304 power point slides lecture 01
Object-oriented concepts
Data communication - Lecture-01
Scalable JavaScript Application Architecture
Linux Administration
CBSE XII Communication And Network Concepts
Ad

Similar to OOP in JavaScript (20)

PPTX
Department of information technology_20250322_133114_0000.pptx
PPTX
Framework prototype
PPTX
Framework prototype
PPTX
Framework prototype
PDF
Object Oriented Programming using JAVA Notes
ODP
Advanced JavaScript Techniques
PPTX
Functions and Objects in JavaScript
PPSX
Oop features java presentationshow
PPTX
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
PPTX
OOPs in Java
PPTX
Object oriented javascript
PPTX
PHP OOP Lecture - 04.pptx
PDF
Principles of Object Oriented Programming
PDF
Demystifying Object-Oriented Programming - PHP UK Conference 2017
PPTX
Object Oriented Programming
PDF
Java inheritance
PPT
Overview of Object Oriented Programming using C++
PPT
packages and interfaces
PDF
OOPS JavaScript Interview Questions PDF By ScholarHat
PDF
OOP in PHP
Department of information technology_20250322_133114_0000.pptx
Framework prototype
Framework prototype
Framework prototype
Object Oriented Programming using JAVA Notes
Advanced JavaScript Techniques
Functions and Objects in JavaScript
Oop features java presentationshow
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPs in Java
Object oriented javascript
PHP OOP Lecture - 04.pptx
Principles of Object Oriented Programming
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Object Oriented Programming
Java inheritance
Overview of Object Oriented Programming using C++
packages and interfaces
OOPS JavaScript Interview Questions PDF By ScholarHat
OOP in PHP

More from manugoel2003 (10)

PPT
Css Specificity
PPT
Subversion (SVN)
PPT
Zend Framework
PPT
Drupal CMS
PPT
Securing Your Web Server
PPS
PHP Security
ODP
Introduction to jQuery
ODP
Drupal Best Practices
PPT
CiviCRM
PPT
PHP Documentor
Css Specificity
Subversion (SVN)
Zend Framework
Drupal CMS
Securing Your Web Server
PHP Security
Introduction to jQuery
Drupal Best Practices
CiviCRM
PHP Documentor

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
A Presentation on Artificial Intelligence
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PDF
cuic standard and advanced reporting.pdf
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
A Presentation on Artificial Intelligence
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
cuic standard and advanced reporting.pdf
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx

OOP in JavaScript

  • 1. OOP in JavaScript “ The World's Most Misunderstood Programming Language” Douglas Crockford
  • 2. Some Myths JavaScript is related to Java JavaScript was developed by Sun Microsystems JavaScript is not Object Oriented JavaScript does not support data hiding, i.e. everything is public
  • 3. OOP Concepts Encapsulation Inheritance Polymorphism
  • 4. Encapsulation Definition Data + Operation Single logically organized unit Data visibility
  • 5. Inheritance Definition Parent-child relationship between classes Child inherits Parents’ characteristics Child can redefine existing characteristics Child can add more characteristics
  • 6. Polymorphism Definition Multiple functions Share a common name Context specific invocation The characteristic of being able to assign a different meaning or usage to something in different contexts ( http://searchsmb.techtarget.com/sDefinition/0,,sid44_gci212803,00.html )
  • 7. Encapsulation Private variables - Can only be accessed by private functions and privileged methods Private functions - Can only be called by privileged methods Privileged methods - May invoked by code external to the object Public properties - May be read/written from outside the object Public methods - Shared methods Prototype properties - Shared properties
  • 8. Encapsulation function Student(name) { var age = 0; var checkAge = function(){ return (age > 0) ? age : false; }; this.getAge = function(){ return (checkAge()) ? age : “Age not set”; } this.setAge = function(_age){ age = _age; } this.name = name; this.constructor.prototype.updateTotal(); } Student.prototype.total = 0; Student.prototype.updateTotal = function(){ this.constructor.prototype.total++; }
  • 9. Inheritance See Listing 1 See Listing 2
  • 11. What more? JSON Closures
  • 12. JSON Object – { } Array – [ ] Separator – , : Var students = [ {name : “abc” , age : 20} , {name : “xyz” , age : 21} ];
  • 13. References http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference http://mckoss.com/jscript/object.htm http://www.sitepoint.com/article/oriented-programming-1 http://www.codeproject.com/aspnet/JsOOP1.asp http://phrogz.net/JS/Classes/OOPinJS.html http://javascript.crockford.com/javascript.html http://kevlindev.com/tutorials/javascript/inheritance/index.htm http://www.dustindiaz.com/javascript-private-public-privileged/ http://developer.yahoo.com/yui/theater/ http://www.dustindiaz.com/json-for-the-masses/ http:// www.json.org / Google + Wikipedia = Many Many more references