Create Object type variable in Javascript

Description

Objects in Javascript groups data and functions.

Objects are created by using the new operator.

var o = new Object();

You can create your own objects by creating instances of the Object type and adding properties and methods to it.

Object instance

The Object type in Javascript is the base for all other objects.

All of the properties and methods of the Object type are also present on other, more specific objects.

Each Object instance has the following properties and methods:

  • constructor - The function used to create the object.
  • hasOwnProperty(propertyName) - tells if a property exists on the object instance (not on the prototype). The property name must be specified as a string (for example, o.hasOwnProperty("name")).
  • isPrototypeOf(object) - Determines if the object is a prototype of another object.
  • propertyIsEnumerable(propertyName) - Indicates if the given property can be enumerated using the for-in statement. The property name must be a string.
  • toLocaleString() - Returns a string representation locale to execution environment.
  • toString() - Returns a string representation of the object.
  • valueOf() - Returns a string, number, or Boolean equivalent of the object. It often returns the same value as toString().




















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions