JScript.NET enables us to create full-fledged .NET applicationsas if we were using a language such as C# or VB.NETby compiling our code into Intermediate Language (IL). One of the great things about this method is that it allows us to use strict data typing and access modifiers, such as private and public properties, which I know seems very alien when thinking of JavaScript. The strict data typing allows for better code readability and much easier debugging methods.

Here is an example of the syntax that you would use to create a JScript.NET object.

<script language="JScript" runat="server"> public class employee (_id, _firstName, _lastName) {     private id : String  = _id;     private firstName : String = _firstName;     private lastName : String = _lastName;     private getFullName : Function = function(e)     {         return this.firstName + " " + this.lastName;     } } </script>

For developers with an OOP background, this approach could be easier to grasp. However, the syntax for the data typing is a bit strange, and the fact that you need to use and install the .NET Framework could be limiting in terms of developmentit really just depends on your situation.

Now that we have a little bit of background on other ways to create an object with JavaScript, we will cover the two approaches that I believe have the most flexibility for what we are trying to accomplish. These next two approaches allow for the creation of multiple objects because of the reusability they lend to JavaScript. Let's take a look.

Ajax for Web Application Developers
Ajax for Web Application Developers
ISBN: 0672329123
EAN: 2147483647
Year: 2007
Pages: 129
Authors: Kris Hadlock

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net