SlideShare a Scribd company logo
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
var Calculator = function() {
     //private variables
     //private functions

     return {
          //public members
     };
};
var Calculator = function(eq) {
     //private member
     var eqCtl = document.getElementById(eq);

     return {
                                      var calculator = new Calculator('eq');
           //expose public member     calculator.add(2,2)
           add: function(x,y) {
                 var val = x + y;
                 eqCtl.innerHTML = val;
                 }
           };
};
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
newObject   oldObject
car   vehicle
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
newObject   Constructor.prototype
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts
Advanced JavaScript Concepts

More Related Content

PDF
Advanced javascript
PDF
Reactive, component 그리고 angular2
PDF
Let's JavaScript
PDF
JavaScript Core
PDF
The Snake and the Butler
PDF
Anonymous functions in JavaScript
PPTX
Oojs 1.1
PDF
Java script object model
Advanced javascript
Reactive, component 그리고 angular2
Let's JavaScript
JavaScript Core
The Snake and the Butler
Anonymous functions in JavaScript
Oojs 1.1
Java script object model

What's hot (20)

PDF
Intro to JavaScript
PDF
Workshop 5: JavaScript testing
PDF
Workshop 10: ECMAScript 6
PPTX
AngularJs $provide API internals & circular dependency problem.
PDF
JavaScript Functions
PPTX
Ian 20150116 java script oop
PDF
Functional Reactive Programming - RxSwift
ZIP
PDF
Swift で JavaScript 始めませんか? #iOSDC
PDF
JavaScript in 2016
PDF
Kotlin Delegates in practice - Kotlin community conf
ODP
From object oriented to functional domain modeling
PDF
Kotlin delegates in practice - Kotlin Everywhere Stockholm
PPTX
Javascript And J Query
PDF
Design Patterns Reconsidered
PDF
Javascript & Ajax Basics
PDF
Cocoa heads 09112017
PDF
06 jQuery #burningkeyboards
PDF
Advanced functional programing in Swift
PPTX
Intro to JavaScript
Workshop 5: JavaScript testing
Workshop 10: ECMAScript 6
AngularJs $provide API internals & circular dependency problem.
JavaScript Functions
Ian 20150116 java script oop
Functional Reactive Programming - RxSwift
Swift で JavaScript 始めませんか? #iOSDC
JavaScript in 2016
Kotlin Delegates in practice - Kotlin community conf
From object oriented to functional domain modeling
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Javascript And J Query
Design Patterns Reconsidered
Javascript & Ajax Basics
Cocoa heads 09112017
06 jQuery #burningkeyboards
Advanced functional programing in Swift
Ad

Viewers also liked (20)

PPTX
Advanced JavaScript
PDF
Advanced JavaScript Techniques
PPT
Advanced Javascript
PPT
Ajax Performance
PPT
The JSON Saga
KEY
Douglas Crockford - Programming Style and Your Brain
PPT
The Theory Of The Dom
PDF
Performance, Games, and Distributed Testing in JavaScript
PDF
Performance Improvements in Browsers
PDF
JavaScript: Past, Present, Future
PPT
Douglas Crockford - Ajax Security
PPTX
JavaScript in Object-Oriented Way
PDF
CSS Sanity with Sass: The Inverted Triangle Approach
PDF
Building a JavaScript Library
PPT
PDF
Prototype
PPTX
SASS - CSS with Superpower
PPTX
A slightly advanced introduction to node.js
PPT
OOP in JavaScript
PDF
Advanced Object-Oriented JavaScript
Advanced JavaScript
Advanced JavaScript Techniques
Advanced Javascript
Ajax Performance
The JSON Saga
Douglas Crockford - Programming Style and Your Brain
The Theory Of The Dom
Performance, Games, and Distributed Testing in JavaScript
Performance Improvements in Browsers
JavaScript: Past, Present, Future
Douglas Crockford - Ajax Security
JavaScript in Object-Oriented Way
CSS Sanity with Sass: The Inverted Triangle Approach
Building a JavaScript Library
Prototype
SASS - CSS with Superpower
A slightly advanced introduction to node.js
OOP in JavaScript
Advanced Object-Oriented JavaScript
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Programs and apps: productivity, graphics, security and other tools
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx

Advanced JavaScript Concepts

  • 13. var Calculator = function() { //private variables //private functions return { //public members }; };
  • 14. var Calculator = function(eq) { //private member var eqCtl = document.getElementById(eq); return { var calculator = new Calculator('eq'); //expose public member calculator.add(2,2) add: function(x,y) { var val = x + y; eqCtl.innerHTML = val; } }; };
  • 26. newObject oldObject
  • 27. car vehicle
  • 31. newObject Constructor.prototype

Editor's Notes

  • #6: a closure is the local variables for a function - kept alive after the function has returned, ora closure is a stack-frame which is not de-allocated even after the function returns. In JavaScript, if you use the function keyword inside another function, you are creating a closure.In C, and most other common languages after a function returns, all the local variables are no longer accessible because the stack-frame is destroyed.Lets see in action…its simple…
  • #24: Before starting ask about Inheritance in JS.A prototype-based language, such as JavaScript, does not make this distinction: it simply has objects. A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object. Any object can specify its own properties, either when you create it or at run time. In addition, any object can be associated as the prototype for another object, allowing the second object to share the first object's properties.
  • #25: Before starting ask about Inheritance in JS.A prototype-based language, such as JavaScript, does not make this distinction: it simply has objects. A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object. Any object can specify its own properties, either when you create it or at run time. In addition, any object can be associated as the prototype for another object, allowing the second object to share the first object's properties.
  • #26: Objects are instances of Classes.A Class inherits from another Class.
  • #27: Note: Proto is available only in Mozilla
  • #28: If an car has a model property, then the chain will not be consulted when accessing member model .If access of a member of car fails, then search for the member in vehicle.If that fails, then search for the member in Object.prototype.Changes in oldObject may be immediately visible in newObject.Changes to newObject have no effect on oldObject.oldObject can be the prototype for an unlimited number of objects which will all inherit its properties.newObject can be the prototype for an unlimited number of even newer objects.There is no limit to the length of the chain (except common sense).
  • #31: When functions are designed to be used with new, they are called constructors.Constructors are used to make objects of a type or class.JavaScript's notation can get a little strange because it is trying to look like the old familiar classical pattern, while also trying to be something really different.
  • #32: When functions are designed to be used with new, they are called constructors.Constructors are used to make objects of a type or class.JavaScript's notation can get a little strange because it is trying to look like the old familiar classical pattern, while also trying to be something really different.new Oppnew Constructor() returns a new object with a link to Constructor.prototype.varnewObject = new Constructor();The new operator is required when calling a Constructor.If new is omitted, the global object is clobbered by the constructor, and then the global object is returned instead of a new instance.
  • #33: The logical OR operator makes sure that, if no values get passed into that constructor function, the properties hasEngine and hasWheels still have values assigned to them. 
  • #34: This is basically the same as above, nothing special. We would now create a new Car object by passing in make, model and hp using the new operator. But for now, Car and Vehicle do not have anything to do with each other at all.
  • #35: This is basically the same as above, nothing special. We would now create a new Car object by passing in make, model and hp using the new operator. But for now, Car and Vehicle do not have anything to do with each other at all.
  • #39: A prototype-based language, such as JavaScript, does not make this distinction: it simply has objects. A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object. Any object can specify its own properties, either when you create it or at run time. In addition, any object can be associated as the prototype for another object, allowing the second object to share the first object's properties.
  • #43: Jst