Class method

We have seen that a method could be assigned to any instance of a given class, or could be put in the class prototype, and having the same behaviour: a full access to all the other properties and methods in the class.

But we can also define a method as class member. This method wouldn't see "this", so could be used only to access class properties and methods.

To create a new class method we simply create it at class level, like this:

BlogEntry.showSignature = function() {

More information on custom objects in chapter ten of Head First JavaScript.

No comments:

Post a Comment