SlideShare a Scribd company logo
Dibyendu Shankar Tiwary Javascript Unleashed (Javascript that you need to know but might not!!)
What is Javascript ? Introduction
It makes the wall to talk Introduction
What’s behind the scene? Introduction
Equation
I know it all Tell me something which I don’t know
Why are we here? JavaScript as a prototype-based language  JavaScript Objects Are Dictionaries   JavaScript Functions Are First Class   Constructor Functions but No Classes   Prototypes   Object-oriented programming with JavaScript Static Properties and Methods   Closures   Simulating Private Properties  Inheriting from Classes Coding tricks with JavaScript   Simulating Namespaces  Classes and Reflection Future of Javascript   Should You Code JavaScript This Way?  Putting It into Perspective
JavaScript Objects Are Dictionaries   Code Demo JavaScript Functions Are First Class   Code Demo Constructor Functions but No Classes Code Demo (Dog spot = new Dog(); ) Prototypes (I deserve to be a header of a slide) As you wish, but be sure you gonna use it. JavaScript as a prototype-based language
Every Function’s Prototype Has a Constructor Property  The prototype object is a central concept in object-oriented programming with JavaScript. Name comes from the idea that in JavaScript, an object is created as a copy of an existing example (that is, a prototype) object every function has a property named "prototype" that refers to a prototype object prototype object in turn has a property named "constructor," which refers back to the function itself (Confused ??) Code Demo : var buddy = new Dog(“Buddy“);  Prototypes (Happy   )
Objects Appear to Have Their Prototype’s Properties  Code Demo Prototypes (Another slide conquered)
Resolving toString() Method in the Prototype Chain Prototypes (Are you kinda hittin on me ??)
Inheriting from a Prototype Changes made to a prototype object are immediately visible to the objects that inherit from it, even after these objects are created. If you define a property/method X in an object, a property/method of the same name will be hidden in that object’s prototype. For instance, you can override Object.prototype’s toString method by defining a toString method in Dog.prototype. Changes only go in one direction, from prototype to its derived objects, but not vice versa. Code Demo Prototypes (Name the session after me)
Static Properties and Methods   Code Demo Closure   A closure is a runtime phenomenon that comes about when an inner function (or in C#, an inner anonymous method) is bound to the local variables of its outer function.  Confused?? ( Code demo is for the rescue) Simulating Private Properties A local variable in a function is normally not accessible from outside the function However, when that local variable is captured by an inner function’s closure, it lives on. Code Demo javascript.crockford.com Inheriting from Classes (Even I deserve a slide, Ok whatever!!) Oops in Javascript
Constructor functions and prototype objects allow you to simulate classes Can simulate private members of a class using closures  You haven’t seen how you can derive from your class A local variable in a function is normally not accessible from outside the function However, when that local variable is captured by an inner function’s closure, it lives on. Code Demo javascript.crockford.com You have a base class Pet, with one derived class Dog.  Stop talking show me the code. Inheritance from Classes (Happy   )
Simulating Namespaces In C++ and C#, namespaces are used to minimize the probability of name collisions Code Demo Classes and Reflection  there is no way to know the name of a function.  it wouldn’t help us in most situations as a class constructor is typically built by assigning an anonymous function to a namespaced variable. The reflection APIs in ASP.NET AJAX work over any type. Coding tips and Tricks in JavaScript
Should You Code JavaScript This Way? Should you code in JavaScript the way you code in C# or C++? Best practices for one language may not be the best practices for another Maybe, as Douglas Crockford says in his article " Prototypal Inheritance in JavaScript ", the JavaScript way of programming is to make prototype objects, and use the simple object function below to make new objects, which inherit from that original object: function object(o) { function F() {} F.prototype = o; return new F(); } Putting It into Perspective   I have found my JavaScript journey a rewarding experience.  Although not entirely without frustration along the way Registering Class Hierarchies and Calling Base.  It’s a journey not a destination. Future of Javscript
Thank you  ( If you are confused now I have done a good job, if not then an exceptional job   )

More Related Content

PDF
PDF
Prototype
PPTX
Js: master prototypes
PPTX
OOP's Part 1
ODP
Constructors, Intro to Ruby Classes Part II
ODP
Intro Ruby Classes Part I
PDF
Javascript Design Patterns
PPT
Ruby for C# Developers
Prototype
Js: master prototypes
OOP's Part 1
Constructors, Intro to Ruby Classes Part II
Intro Ruby Classes Part I
Javascript Design Patterns
Ruby for C# Developers

What's hot (20)

PPTX
All of javascript
PDF
JavaScript Patterns
PDF
Js fwdays unit tesing javascript(by Anna Khabibullina)
PPTX
JS Frameworks Day April,26 of 2014
PDF
Effective Scala: Programming Patterns
PPTX
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
PDF
Effective Scala (SoftShake 2013)
PPTX
“Insulin” for Scala’s Syntactic Diabetes
PPT
Douglas Crockford Presentation Goodparts
PDF
JavaScript - From Birth To Closure
PPTX
Comparing Golang and understanding Java Value Types
PPTX
All of Javascript
PDF
Effective Scala (JavaDay Riga 2013)
PPTX
JavaScript in Object-Oriented Way
ODP
Javascript
PDF
Dependency Injection Why is it awesome and Why should I care?
PDF
TypeScript Best Practices
PPT
Goodparts
PPTX
Clean Code: Stop wasting my time
PDF
Scalable JavaScript Design Patterns
All of javascript
JavaScript Patterns
Js fwdays unit tesing javascript(by Anna Khabibullina)
JS Frameworks Day April,26 of 2014
Effective Scala: Programming Patterns
Advanced Object Oriented JavaScript (prototype, closure, scope, design patterns)
Effective Scala (SoftShake 2013)
“Insulin” for Scala’s Syntactic Diabetes
Douglas Crockford Presentation Goodparts
JavaScript - From Birth To Closure
Comparing Golang and understanding Java Value Types
All of Javascript
Effective Scala (JavaDay Riga 2013)
JavaScript in Object-Oriented Way
Javascript
Dependency Injection Why is it awesome and Why should I care?
TypeScript Best Practices
Goodparts
Clean Code: Stop wasting my time
Scalable JavaScript Design Patterns
Ad

Viewers also liked (11)

PPTX
Ch 7 interpersonal
DOCX
Plan de entrenamiento ef
PPTX
Chapter 13: Using Good Language Skills
PPS
Facil y dificil
DOCX
4) Resume Of Chaudhary Attique
PDF
Chapter 2
PPTX
CH 6: Adapting Our Speech
DOC
Worksheethealthyhabits 100207070236-phpapp02
PDF
MANIPULACION DE CARPETAS
DOC
Worksheetunhealthyhabits 100207070228-phpapp01
Ch 7 interpersonal
Plan de entrenamiento ef
Chapter 13: Using Good Language Skills
Facil y dificil
4) Resume Of Chaudhary Attique
Chapter 2
CH 6: Adapting Our Speech
Worksheethealthyhabits 100207070236-phpapp02
MANIPULACION DE CARPETAS
Worksheetunhealthyhabits 100207070228-phpapp01
Ad

Similar to Java script unleashed (20)

PDF
OOPS JavaScript Interview Questions PDF By ScholarHat
PPTX
Object oriented javascript
PPTX
JavaScript Beyond jQuery
PDF
Intro to OOP
PPTX
Javascript Prototypal Inheritance - Big Picture
PPTX
JavaScript OOPS Implimentation
PPTX
Modeling Patterns for JavaScript Browser-Based Games
PDF
JavaScript Programming
PPTX
Java scriptforjavadev part2a
PPT
Oop java
PPS
Master in javascript
PPTX
Javascriptinobject orientedway-090512225827-phpapp02
PPT
A Deeper look into Javascript Basics
PPTX
How to not suck at JavaScript
PPTX
Modern JavaScript Development @ DotNetToscana
PDF
PPT
Java Script Patterns
PDF
Your java script library
PPT
JavaScript Workshop
OOPS JavaScript Interview Questions PDF By ScholarHat
Object oriented javascript
JavaScript Beyond jQuery
Intro to OOP
Javascript Prototypal Inheritance - Big Picture
JavaScript OOPS Implimentation
Modeling Patterns for JavaScript Browser-Based Games
JavaScript Programming
Java scriptforjavadev part2a
Oop java
Master in javascript
Javascriptinobject orientedway-090512225827-phpapp02
A Deeper look into Javascript Basics
How to not suck at JavaScript
Modern JavaScript Development @ DotNetToscana
Java Script Patterns
Your java script library
JavaScript Workshop

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Insiders guide to clinical Medicine.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Classroom Observation Tools for Teachers
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Lesson notes of climatology university.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Pre independence Education in Inndia.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RMMM.pdf make it easy to upload and study
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Types and Its function , kingdom of life
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Microbial disease of the cardiovascular and lymphatic systems
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Insiders guide to clinical Medicine.pdf
VCE English Exam - Section C Student Revision Booklet
Sports Quiz easy sports quiz sports quiz
Classroom Observation Tools for Teachers
01-Introduction-to-Information-Management.pdf
Lesson notes of climatology university.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
O7-L3 Supply Chain Operations - ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pre independence Education in Inndia.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
RMMM.pdf make it easy to upload and study

Java script unleashed

  • 1. Dibyendu Shankar Tiwary Javascript Unleashed (Javascript that you need to know but might not!!)
  • 2. What is Javascript ? Introduction
  • 3. It makes the wall to talk Introduction
  • 4. What’s behind the scene? Introduction
  • 6. I know it all Tell me something which I don’t know
  • 7. Why are we here? JavaScript as a prototype-based language JavaScript Objects Are Dictionaries JavaScript Functions Are First Class Constructor Functions but No Classes Prototypes Object-oriented programming with JavaScript Static Properties and Methods Closures Simulating Private Properties Inheriting from Classes Coding tricks with JavaScript Simulating Namespaces Classes and Reflection Future of Javascript Should You Code JavaScript This Way? Putting It into Perspective
  • 8. JavaScript Objects Are Dictionaries Code Demo JavaScript Functions Are First Class Code Demo Constructor Functions but No Classes Code Demo (Dog spot = new Dog(); ) Prototypes (I deserve to be a header of a slide) As you wish, but be sure you gonna use it. JavaScript as a prototype-based language
  • 9. Every Function’s Prototype Has a Constructor Property  The prototype object is a central concept in object-oriented programming with JavaScript. Name comes from the idea that in JavaScript, an object is created as a copy of an existing example (that is, a prototype) object every function has a property named "prototype" that refers to a prototype object prototype object in turn has a property named "constructor," which refers back to the function itself (Confused ??) Code Demo : var buddy = new Dog(“Buddy“); Prototypes (Happy  )
  • 10. Objects Appear to Have Their Prototype’s Properties Code Demo Prototypes (Another slide conquered)
  • 11. Resolving toString() Method in the Prototype Chain Prototypes (Are you kinda hittin on me ??)
  • 12. Inheriting from a Prototype Changes made to a prototype object are immediately visible to the objects that inherit from it, even after these objects are created. If you define a property/method X in an object, a property/method of the same name will be hidden in that object’s prototype. For instance, you can override Object.prototype’s toString method by defining a toString method in Dog.prototype. Changes only go in one direction, from prototype to its derived objects, but not vice versa. Code Demo Prototypes (Name the session after me)
  • 13. Static Properties and Methods Code Demo Closure A closure is a runtime phenomenon that comes about when an inner function (or in C#, an inner anonymous method) is bound to the local variables of its outer function. Confused?? ( Code demo is for the rescue) Simulating Private Properties A local variable in a function is normally not accessible from outside the function However, when that local variable is captured by an inner function’s closure, it lives on. Code Demo javascript.crockford.com Inheriting from Classes (Even I deserve a slide, Ok whatever!!) Oops in Javascript
  • 14. Constructor functions and prototype objects allow you to simulate classes Can simulate private members of a class using closures You haven’t seen how you can derive from your class A local variable in a function is normally not accessible from outside the function However, when that local variable is captured by an inner function’s closure, it lives on. Code Demo javascript.crockford.com You have a base class Pet, with one derived class Dog. Stop talking show me the code. Inheritance from Classes (Happy  )
  • 15. Simulating Namespaces In C++ and C#, namespaces are used to minimize the probability of name collisions Code Demo Classes and Reflection there is no way to know the name of a function. it wouldn’t help us in most situations as a class constructor is typically built by assigning an anonymous function to a namespaced variable. The reflection APIs in ASP.NET AJAX work over any type. Coding tips and Tricks in JavaScript
  • 16. Should You Code JavaScript This Way? Should you code in JavaScript the way you code in C# or C++? Best practices for one language may not be the best practices for another Maybe, as Douglas Crockford says in his article " Prototypal Inheritance in JavaScript ", the JavaScript way of programming is to make prototype objects, and use the simple object function below to make new objects, which inherit from that original object: function object(o) { function F() {} F.prototype = o; return new F(); } Putting It into Perspective I have found my JavaScript journey a rewarding experience. Although not entirely without frustration along the way Registering Class Hierarchies and Calling Base. It’s a journey not a destination. Future of Javscript
  • 17. Thank you ( If you are confused now I have done a good job, if not then an exceptional job  )

Editor's Notes

  • #2: Hi, welcome everybody. Today let’s discuss about virtualization and how it helps to improve our productivity during day to day software development.
  • #3: . How the javascript evolution came to the being of what it is today, we have always designated javascript as a second fiddle language in our programming careers.
  • #4: The web becomes interactive and the wall talks back, it powers the web pages which start listening to your needs.
  • #5: Javascript sits with HTML abd CSS as one of the three pieces of modern web page construction. One must follow the trail of the structure (HTML), to style (CSS), and then to action (Javascript)
  • #9: So we’ve seen ways to create an object, complete with its properties and methods. But if you notice all the snippets above, the properties and methods are hardcoded within the object definition itself. What if you need more control over the object creation? For example, you may need to calculate the values of the object’s properties based on some parameters. Or you may need to initialize the object’s properties to the values that you’ll only have at run time. Or you may need to create more than one instance of the object, which is a very common requirement. In C#, we use classes to instantiate object instances. But JavaScript is different since it doesn’t have classes. Instead, as you’ll see in the next section, you take advantage of the fact that functions act as constructors when used together with the "new" operator.
  • #10: The prototype object is a central concept in object-oriented programming with JavaScript. Name comes from the idea that in JavaScript, an object is created as a copy of an existing example (that is, a prototype) object every function has a property named "prototype" that refers to a prototype object prototype object in turn has a property named "constructor," which refers back to the function itself (Confused ??) Code Demo : var buddy = new Dog(“Buddy“);
  • #12: Refer to the code in 4Prototype.aspx