Javascript [Electronic resources] : The Definitive Guide (4th Edition) نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Javascript [Electronic resources] : The Definitive Guide (4th Edition) - نسخه متنی

David Flanagan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید

Availability


JavaScript 1.0; JScript 1.0; ECMAScript
v1


Synopsis

this

Global Properties


The
global object is not a class, so the following global properties have
individual reference entries under their own name. That is, you can
find details on the undefined property listed
under the name "undefined," not under
"Global.undefined." Note that all top-level variables are
also properties of the global object.

Infinity

A numeric value that represents positive infinity.

NaN

The not-a-number value.

undefined

The undefined value.


Global Functions


The
global object is an object, not a class. The global functions listed
below are not methods of any object, and their reference entries
appear under the function name. For example, you'll find
details on the parseInt( ) function under
"parseInt( )," not "Global.parseInt( )."

decodeURI( )

Decodes a string escaped with encodeURI( ).

decodeURIComponent( )

Decodes a string escaped with encodeURIComponent( ).

encodeURI

Encodes a URI by escaping certain characters.

encodeURIComponent

Encodes a URI component by escaping certain characters.

escape( )

Encodes a string by replacing certain characters with escape
sequences.

eval( )

Evaluates a string of JavaScript code and return the result.

isFinite( )

Tests whether a value is a finite number.

isNaN

Tests whether a value is the not-a-number value.

parseFloat( )

Parses a number from a string.

parseInt( )

Parses an integer from a string.

unescape( )

Decodes a string encoded with escape( ).


Global Objects





In
addition to the global properties and functions listed above, the
global object also defines properties that refer to all the other
predefined JavaScript objects. All of these properties are
constructor functions that define classes except for
Math, which is a reference to an object that is
not a constructor.

Array

The Array( ) constructor.

Boolean

The Boolean( ) constructor.

Date

The Date( ) constructor.

Error

The Error( ) constructor.

EvalError

The EvalError( ) constructor.

Function

The Function( ) constructor.

Math

A reference to an object that defines mathematical functions.

Number

The Number( ) constructor.

Object

The Object( ) constructor.

RangeError

The RangeError( ) constructor.

ReferenceError

The ReferenceError( ) constructor.

RegExp

The RegExp( ) constructor.

String

The String( ) constructor.

SyntaxError

The SyntaxError( ) constructor.

TypeError

The TypeError( ) constructor.

URIError

The URIError( ) constructor.


Description


The global object is a predefined object
that serves as a placeholder for the global properties and functions
of JavaScript. All other predefined objects, functions, and
properties are accessible through the global object. The global
object is not a property of any other object, so it does not have a
name. (The title of this reference page was chosen simply for
organizational convenience and does not indicate that the global
object is named "Global"). In top-level JavaScript code,
you can refer to the global object with the keyword
this. It is rarely necessary to refer to the
global object in this way, however, because the global object serves
as the top of the scope chain, which means that unqualified variable
and function names are looked up as properties of the object. When
JavaScript code refers to the parseInt( )
function, for example, it is referring to the
parseInt property of the global object. The fact
that the global object is the top of the scope chain also means that
all variables declared in top-level JavaScript code become properties
of the global object.

The global object is simply an object, not a class. There is no
Global( ) constructor, and there is no way to
instantiate a new global object.

When JavaScript is embedded in a particular environment, the global
object is usually given additional properties that are specific to
that environment. In fact, the type of the global object is not
specified by the ECMAScript standard, and an implementation or
embedding of JavaScript may use an object of any type as the global
object, as long as the object defines the basic properties and
functions listed here. In client-side JavaScript, for example, the
global object is a Window object and represents the web browser
window within which the JavaScript code is running.


Example


In core JavaScript, none of the predefined properties of the global
object are enumerable, so you can list all implicitly and explicitly
declared global variables with a
for/in loop like this:

var variables = "
for(var name in this)
variables += name + "\n";


See Also


Window in the client-side reference section; Chapter 4

/ 844