Availability
JavaScript objectsJavaScript 1.0; JScript 1.0; ECMAScript v1
Constructor
new Object( )newObject(value)
Arguments
value
This optional argument specifies a primitive JavaScript value -- a
number, boolean, or string -- that is to be converted to a Number,
Boolean, or String object. This object is not supported prior to
JavaScript 1.1 and ECMAScript v1.
Returns
If no value argument is passed, this
constructor returns a newly created Object instance. If a primitive
value argument is specified, the
constructor creates and returns a Number, Boolean, or String object
wrapper for the primitive value. When the Object(
) constructor is called as a function, without the
new operator, it behaves just as it does when used
with the new operator.
Properties
constructor
A reference to the JavaScript function that was the constructor for
the object.
Methods
hasOwnProperty( )
Checks whether an object has a locally defined (noninherited)
property with a specified name.
isPrototypeOf( )
Checks whether this object is the prototype object of a specified
object.
propertyIsEnumerable( )
Checks whether a named property exists and would be enumerated by a
for/in loop.
toLocaleString( )
Returns a localized string representation of the object. The default
implementation of this method simply calls toString(
), but subclasses may override it to provide localization.
toString( )
Returns a string representation of the
object. The implementation of this
method provided by the Object class is quite generic and does not
provide much useful information. Subclasses of Object typically
override this method by defining their own toString(
) method which produces more useful output.
valueOf( )
Returns the primitive value of the object, if any. For objects of
type Object, this method simply returns the object itself. Subclasses
of Object, such as Number and Boolean, override this method to return
the primitive value associated with the object.
Description
The Object class is a built-in data type
of the JavaScript language. It serves as the superclass for all other
JavaScript objects; therefore, methods and behavior of the Object
class are inherited by all other objects. The basic behavior of
objects in JavaScript is explained in Chapter 8.
In addition to the Object( ) constructor shown
above, objects can also be created and initialized using the Object
literal syntax described in Chapter 8.
See Also
Array, Boolean, Function, Function.prototype, Number, String; Chapter 8
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.