Share

From this page you can share Object Oriented JavaScript - Should You Use It? - Part 3 to a social bookmarking site or email a link to the page.
Social WebE-mail
Enter multiple addresses on separate lines or separate them with commas.
Object Oriented JavaScript - Should You Use It? - Part 3
(Your Name) has forwarded a page to you from Ajaxonomy
(Your Name) thought you would like to see this page from the Ajaxonomy web site.

Object Oriented JavaScript - Should You Use It? - Part 3

Tagged:  

So we have come to the last of my articles on object oriented JavaScript. You can read the last post by click ing here. This post will be about how JavaScript is proposed to change when (or if as the case may be) ECMAScript 4 (the spec that JavaScript is based on) is supported by the major browsers.

One of the changes that I am most happy about is the new proposed class structure. Yes JavaScript in the near future will be an object oriented language that is more in-line with languages like Java and C#.

Below is how the new structure is proposed.

Classes: A class describes an object by presenting those properties (fields) of the object that are always present (the
fixed properties or fixtures), including variables, constants, and methods16:

class C {
	var val // a variable property
	var large = Infinity // a variable property
	const x = 3.14 // a constant property
	function f(n) { return n+val*2 } // a method property
}

You would create instances of the class using the new method, just as you currently would with the current JavaScript object.

So, the answer to the question of should you use object oriented JavaScript is a resounding, Yes, especially with the direction that it looks like the language is going. For a more information on ECMAScript 4 check out ecmascript.org. To go directly to an overview of ECMAScript 4 script click here.

As always if you have any questions you can leave them in the comments or private message me once you login to this site. Also, if you have anything that you would like to blog about on this site all registered users get their own blog on Ajaxonomy and the most interesting posts will be published to the home page.