IE 5.5: Formatting, URIs, and Stack Operations : Detecting Object-Property Ownership | WebReference

IE 5.5: Formatting, URIs, and Stack Operations : Detecting Object-Property Ownership


IE 5.5: Formatting, URIs, and Stack Operations

Detecting Object-Property Ownership

IE5.5 introduced a score of new operators and methods for detecting various object-property relationships. The in operator checks if a given property is defined for a given object. Suppose the object line is of type Array:

line = new Array("aaa", "bbb", "ccc", "ddd", "eee");

We know that the object line inherited the Array's properties such as its length. If we check whether length is in line (length in line), we should get a true value. Notice that the array should not be empty, or else the returned answer will be a false value.

Similarly, the method hasOwnProperty does exactly what the in operator does. The expression line.hasOwnProperty(length) should return a true value.

The method propertyIsEnumerable() checks, again, that the given property belongs to the given object. Once it belongs, every property is automatically enumerable in the for...in loops. The for...in loop loops through the existing properties of a given object. The check line.propertyIsEnumerable(length) should return a true value.

Next: How to encode and decode URIs

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: March 14, 2000
Revised: April 26, 2000

URL: http://www.webreference.com/js/column59/6.html