JavaScript Object local objects, built-in objects, and host objects

Source: Internet
Author: User
Tags natural logarithm square root hosting

In JavaScript, an object has an attribute (attribute), an attribute can be the original value, or a reference value can be made. If the attribute holds a function, it is treated as a method of the object, otherwise the attribute is considered a property.

The object is created with the name of the class that is instantiated with the keyword new, for example:

var o=new Object ();

You can also use

var o=new Object;

var o={};

Object Abolition

The object's reference is set to null, and the object can be forcibly revoked.

var o=new Object ();

O=null;

Early binding and late binding

The so-called binding , which is the method of combining an object's interface with an object instance.

Early binding (early binding) is the attribute and method of defining an object before it is instantiated, so that the compiler or interpreter can convert it in advance and its code. JavaScript is not a strongly typed language and does not support early binding.

Late binding (late binding) refers to the type of object that the compiler or interpreter does not know before it runs. With late binding, there is no need to check the object's type, just check to see if the object supports attributes and methods. all JavaScript variables are using the late binding method.

Local Objects :

An object that is provided independently of the host environment's ECMAScript implementation. They include:

object           function           array            String

boolean          number            date             regexp

error            EvalError         rangeerror      referenceerror

Syntaxerro TypeError urierror

built-in objects Global and Math

all objects provided by the Ecmasscript implementation that are independent of the hosting environment.

global object is ecmascript good, the most special object, because it does not exist at all. Say it does not exist because in ecmascript, there is no independent function, all functions must be a method of an object. For example, isnam (), Isfinite (), parseint () and parsefloat (), etc., are

encodeuri () and encodeuricomponent () method for encoding passed to the browser uri. The main difference between the two is that encodeuri () does not encode special characters in uri, such as colons, slashes, question marks, and pound signs, while encodeURIComponent () encodes all non-standard characters it finds. And to should decodeuri () and decodeuricomponent () decoding function. These uri method encodeuri (), decodeuri (), encodeURIComponent () and decodeuricomponent () in place of bom () method. uri methods are preferable because they encode all unicode symbols, while bom method can only ascii symbols are correctly encoded. Try to avoid using escape () and () methods.

List of properties for the global object:

Property

Description

Undefined

Undefined type of literal

NaN

Private numeric value of non-number

Infinity

Dedicated numeric value for infinity

Object

Constructor for object

Array

The constructor of the array

Function

Constructor for function

Boolean

Boolean constructor

String

Constructor for string

Number

The constructor of number

Date

Constructor for date

Regexp

The RegExp constructor

Error

The constructor for error

Evalerror

The Evalerror constructor

Rangeerror

The Rangeerror constructor

Referenceerror

The Referenceerror constructor

SyntaxError

SyntaxError Constructor Constructor

TypeError

The TypeError constructor

Urierror

The Urierror constructor

Math Object

The Math object has several objects, primarily mathematical-specific values:

Property

Description

E

Value E, base of natural logarithm

LE10

Natural logarithm of 10

LN2

Natural logarithm of 2

Log2e

logarithm of base e of 2

log10e

logarithm of base e of 10

Pi

Value ∏

Sqrt1_2

Square root of 1/2

SQRT2

Square root of 2

Min () and Max () methods

Used to determine the minimum and maximum values in a set of numbers, both of which accept any parameter and return the minimum maximum value after the comparison .

var Imax=math.max (2,0,6,4); //imax:6

var imin=math.min (2,0,6,4); //imin:0

The ABS () method returns the absolute value of a number.

Ceil () means rounding up

Floor () means rounding down

Rounding of round () standard

Math.ceil (20.5) //returns

Math.floor (20.5) //returns

Math.Round (20.5) //returns

The POW () method is used to raise the specified number to the specified power.

The sqrt () method is used to return the square root of a specified number

The exp () method is used to raise the MATH.E to the specified power

The log () method is used to return the natural logarithm of a specific number

Trigonometric function

Method

Description

ACOs (x)

Returns the inverse cosine value of x

ASIN (x)

Returns the inverse sine of x

Atan (x)

Returns the inverse tangent value of x

ATAN2 (y,x)

Returns the inverse cosine value of the y/x

COS (x)

Returns the cosine value of x

Sin (x)

Returns the sinusoidal value of x

Tan (x)

Returns the tangent value of x

The Math.random () method, which returns a random number from 0 to 1, excluding 0 and 1.

Host Object

All non-local objects are objects provided by the hosting environment that the host object is the ECMAScript implementation of. All BOM and DOM objects are host objects.

JavaScript Object local objects, built-in objects, and host objects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.