Object-Oriented Programming with JavaScript, Part II: Methods - Doc JavaScript | WebReference

Object-Oriented Programming with JavaScript, Part II: Methods - Doc JavaScript


Object-Oriented Programming with JavaScript, Part II: Methods

In this column we conclude our short series about Object-Oriented Programming (00P) with JavaScript. In Part I of this series, we covered the fundamentals. In this column, we focus more on encapsulation, especially on methods.

As we discussed in the first part of this series, JavaScript's support of object-oriented programming is quite impressive. Even though there are no formal classes or instances, there are objects, prototypes, and methods that mimic them. In fact, it is the methods that make the language so vibrant and powerful. You use methods to mimic class inheritance between objects. We'll show you how to define functions in JavaScript, and how to define methods with these functions. We'll show you where method definition does not match the rules for functions. We'll explain the exposure of private data elements, and how to protect them. In this column, we also cover contexts, scopes, and context switching. Understanding contexts and scopes will help you in writing as well as debugging complex scripts.

The examples in this column are for JavaScript 1.1 and above, for both Internet Explorer and Netscape, unless noted otherwise.

In this column, you will learn:

Next: How to construct an object from the Object object

https://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: March 26, 2001
Revised: March 26, 2001

URL: https://www.webreference.com/js/column80/index.html