JavaScript Tutorial/Object Oriented/Introduction

Материал из Web эксперт
Перейти к: навигация, поиск

Declaration and Instantiation

Objects are created by using the new keyword followed by the name of the class.

var oObject = new Object();
var oStringObject = new String();

Dereferencing Objects

JavaScript has a garbage collection routine.

When there are no remaining references to an object, the object is said to be dereferenced.

It is possible to forcibly dereference objects by setting all its references equal to null.

var oObject = new Object;
oObject = null;

Native Objects

ECMA-262 defines native objects as "any object supplied by an JavaScript implementation independent of the host environment."

Object        Function      Array         String
Boolean       Number        Date          RegExp
Error         EvalError     RangeError    ReferenceError
SyntaxError   TypeError     URIError