views:

381

answers:

2

According to this article it should be a Javascript 2.0 way to define class. However, I never saw that in practice. Thus the question. How to use class keyword and what is the difference between Javascript 1.x way of doing things?

+1  A: 

You never saw it in practice because nothing supports JavaScript 2.0. That draft is from a specification that died before being anything other than draft.

David Dorward
+6  A: 

The reason you never saw the class keyword used in practice is that all the current implementations of JavaScript are 1.x.

JavaScript 2.0 was merged into ECMAScript 4 which was rather unpopular and so never made it into the real world.

So to answer your question, how do you use the class keyword? You can't.

Dave Webb
Thank you for your comment.Funny thing though. Visual studio 2008 recognizes it as a valid keyword when writing JavaScript file.
Vladimir Kocjancic
@Validimir - VS2008 probably recognises the class keyword as you can use it in JScript.NET.
Dave Webb
class (along with lots of other java keywords) is a reserved word so that, theoretically, the language can add support without breaking existing programs. There's a full list at https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Reserved_Words.
Matthew Crumley