1124 Part IV . JavaScript Core Language Reference (Database web hosting)

1124 Part IV . JavaScript Core Language Reference Accessing an object object properties and methods: objectReference.property | method([parameters]) Compatibility NN2 ( ) NN3 . NN4 . NN6 . IE3/J1 ( ) IE3/J2 . IE4 . IE5 . IE5.5 . About this object While it might sound like doubletalk, the Object object is a vital native object in the JavaScript environment. It is the root object on which all other native objects such as Date, Array, String, and the like are based. This object also provides the foundation for creating custom objects, as described earlier in this chapter. By and large, your scripts do not access the properties of the native Object object. The same is true for many of its methods, such as toString()and valueOf(), which internally allow debugging alert dialog boxes (and The Evaluator) to display something when referring to an object or its constructor. You can use a trio of methods, described next, in IE5.5 and NN6 to perform some inspection of the prototype environment of an object instance. They are of interest primarily to advanced scripters who are building extensive, simulated object- oriented applications. Methods hasOwnProperty( propName ) Returns: Boolean. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . The hasOwnProperty() method returns true if the current object instance has the property defined in its constructor or in a related constructor function. But if this property is defined externally, as via assignment to the object s prototype property, the method returns false. Using the example of the car and carInLotobjects from earlier in this chapter, the following expressions evaluate to true: car1.hasOwnProperty( spaceNum ) car1.hasOwnProperty( model ) Even though the model property is defined in a constructor that is invoked by another constructor, the property belongs to the car1object. The following statement, however, evaluates to false: car1.hasOwnProperty( companyOwned ) This property is defined by way of the prototype of one of the constructor functions and is not a built-in property for the object instance. objectObject.hasOwnProperty()
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply