KEMBAR78
Java script unleashed | PPT
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   )

Java script unleashed

  • 1.
    Dibyendu Shankar TiwaryJavascript Unleashed (Javascript that you need to know but might not!!)
  • 2.
    What is Javascript? Introduction
  • 3.
    It makes thewall to talk Introduction
  • 4.
    What’s behind thescene? Introduction
  • 5.
  • 6.
    I know itall Tell me something which I don’t know
  • 7.
    Why are wehere? 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 AreDictionaries 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 PrototypeHas 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 toHave Their Prototype’s Properties Code Demo Prototypes (Another slide conquered)
  • 11.
    Resolving toString() Methodin the Prototype Chain Prototypes (Are you kinda hittin on me ??)
  • 12.
    Inheriting from aPrototype 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 andMethods 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 andprototype 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 InC++ 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 CodeJavaScript 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