A JScript object is an encapsulation of data and functionality. Objects are composed of properties (values) and methods (functions). Properties are the data component of the object, while methods provide the functionality to manipulate the data or the object. JScript supports five kinds of objects: intrinsic objects, prototype-based objects, class-based objects, host objects (provided by a host, such as Response in ASP.NET) and .NET Framework classes.
The new operator in conjunction with the constructor function for the selected object creates and initializes an instance of an object. Here are a few examples that use constructors.
var myObject = new Object(); // Creates a generic object. var birthday = new Date(1961, 5, 10); // Creates a Date object. var myCar : Car = new Car("Pinto"); // Creates a user-defined object.
JScript supports two types of user-defined objects (class-based and prototype-based). Both types have unique advantages and disadvantages. Prototype-based objects are dynamically extensible, but they are slow and do not interoperate efficiently with objects from other .NET Framework languages. Class-based objects, on the other hand, can extend existing .NET Framework classes, help provide type safety, and help foster efficient operation. Class-based objects can be dynamically extensible (like prototype-based objects) by defining the class with the expando modifier.