Exforsys.com
 

Sponsored Links

 

Online Training

Career Series

 
 

In this chapter, you'll learn about OOP (Object-Oriented Programming) and how it relates to JavaScript. As an ASP.NET developer, you probably have some experience working with objects, and you may even be familiar with concepts such as inheritance.

However, unless you're already an experienced JavaScript programmer, you probably aren't familiar with the way JavaScript objects and functions really work. This knowledge is necessary in order to understand how the Microsoft AJAX Library works, and this chapter will teach you the necessary foundations. More specifically, you will learn:

  • What encapsulation, inheritance, and polymorphism mean
  • How JavaScript functions work
  • How to use anonymous functions and closures
  • How to read a class diagram, and implement it using JavaScript code
  • How to work with JavaScript prototypes
  • How the execution context and scope affect the output of JavaScript functions
  • How to implement inheritance using closures and prototypes
  • What JSON is, and what a JSON structure looks like

Microsoft AJAX Library Essentials - http://www.packtpub.com/ajax-csharp-essentials/book


 
14 Articles.  

Microsoft AJAX Library Essentials Client-side ASP.NET AJAX 1.0 Explained By Cristian Darie Bogdan Brinzarea. A practical tutorial to enhancing the user experience of your ASP.NET web applications with the final release of the Microsoft AJAX Library What is Microsoft Ajax Library Microsoft Ajax Library or otherwise known as Asynchronous JavaScript...

Object-Oriented JavaScript In this chapter you ll learn about OOP Object-Oriented Programming and how it relates to JavaScript. As an ASP.NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance. However unless you re already an experienced JavaScript programmer you...

Object-Oriented JavaScript Objects and classes are implemented differently in JavaScript than in languages such as C VB.NET Java or C . However when it comes to using them you ll feel on familiar ground. You create objects using the new operator and you call their methods or access their fields using the syntax you already know from C . Here...

JavaScript Functions A simple fact that was highlighted in the previous chapter but that is often overlooked is key to understanding how objects in JavaScript work code that doesn t belong to a function is executed when it s read by the JavaScript interpreter while code that belongs to a function is only executed when that function is called. Take...

Functions as Variables In JavaScript functions are first-class objects. This means that a function is regarded as a data type whose values can be saved in local variables passed as parameters and so on. For example when defining a function you can assign it to a variable and then call the function through this variable. Take this example geshibot...

Anonymous Functions Anonymous functions can be created adhoc and used instead of a named function. Although this can hinder readability when the function is more complex you can do this if you don t intend to reuse a function s code. In the following example we pass such an anonymous function to DisplayGreeting instead of passing GetCurrentHour...

JavaScript Classes Not only can JavaScript functions contain other functions but they can also be instantiated. This makes JavaScript functions a good candidate for implementing the concept of a class from traditional object-oriented programming. This is very helpful feature indeed because JavaScript doesn t support the notion of a class in the classic...

C and JavaScript Classes For the purpose of demonstrating a few more OOP-related concepts we ll use another class. Our new class is named Table and it has two public fields rows columns and one method getCellCount . The getCellCount method should return the number of rows multiplied by the number of columns. The class constructor should...

Thinking of Objects as Associative Arrays A key element in understanding JavaScript objects is understanding the notion of associative arrays which are nothing more than collections of key value pairs. As a .NET developer you have worked with associative arrays represented by classes such as NameValueCollection Hashtable dictionaries and others....

Creating Object Members on the Fly One major difference between OOP in C and ASP.NET and OOP in JavaScript is that JavaScript allows creating object members on the fly" . This is true for objects and classes that you create yourself and also for JavaScript s own objects and types as well. Here s an example where we add a field named ImADate...

JavaScript Execution Context In this section we ll take a peek under the hood of the JavaScript closures and the mechanisms that allow us to create classes objects and object members in JavaScript. For most cases understanding these mechanisms isn t absolutely necessary for writing JavaScript code— so you can skip it if it sounds too advanced....

Inheritance using Closures and Prototypes There are two significant techniques for implementing the OOP concept of inheritance with JavaScript code. The first technique uses closures and the other technique makes use of a feature of the language named prototyping. Early implementations of the Microsoft AJAX library made use of closures-based inheritance...

Inheritance using Prototypes Once again prototyping can help us implement an OOP feature in a more elegant way than when using closures. Prototype-based inheritance makes use of the behavior of JavaScript prototypes. When accessing a member of a function that member will be looked for in the function itself. If it s not found there the member is...

Introducing JSON In AJAX applications client-server communication is usually packed in XML documents or in the JSON JavaScript Object Notation format. Interestingly enough JSON s popularity increased together with the AJAX phenomenon although the AJAX acronym includes XML. JSON is the format used by the Microsoft AJAX Library and the ASP.NET...

14 Articles.  

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 

Latest Comments

 
 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape