JScript Objects
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.
In This Section
Intrinsic Objects
Lists some of the common objects used in JScript scripts and links to information that describes how to use them.Class-based Objects
Provides a guide to using the JScript class-based object model and describes how to define classes (with methods, fields, and properties), how to define a class that inherits from another class, and how to define expando classes.Prototype-based Objects
Provides a guide to using the JScript prototype-based object model and links to information that describes custom constructor functions and inheritance for prototype-based objects.
Related Sections
JScript Data Types
Includes links to topics that explain how to use primitive data types, reference data types, and .NET Framework data types in JScript.JScript Reference
Lists elements that comprise JScript Language Reference and links to topics that explain the details behind the proper use of language elements.Introduction to ASP.NET
Introduces ASP.NET, explains how it can be used with any .NET compatible language, including JScript, to create enterprise-class Web applications, and links to reference information.Introduction to the .NET Framework Class Library
Introduces the .NET Framework class library, explains naming conventions and system namespaces, and links to reference information.