JavaScript Tutorial/Object Oriented/Introduction

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

Declaration and Instantiation

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



   <source lang="javascript">

var oObject = new Object(); var oStringObject = new String();</source>


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.



   <source lang="javascript">

var oObject = new Object; oObject = null;</source>


Native Objects

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



   <source lang="javascript">

Object Function Array String Boolean Number Date RegExp Error EvalError RangeError ReferenceError SyntaxError TypeError URIError</source>