Extensions of javascript Error, Function, Boolean, and Number native types

Source: Internet
Author: User

Error native type
Indicates the error object.
-- EvalError, URLError, RangeError, etc.
Capture Method
-- Try {throw new Error ()} catch (e ){}
-- In theory, throw can be used as the intended object.
Public attribute of the Error object IE and FireFox
-- Message: error message

Error browser-specific attributes
IE:
-- Description: Same as message Property
-- Number: error number. Only errors thrown by the script engine have attributes.
FireFox:
-- FileName: creates an incorrect file.
-- LineNumber: the row number of the error object.
-- Stack: stack information when an error is created

Extension of the Error native type
Error. create (message, errorinfo) Method
-- Create a new Error object
-- Set the message attribute of the Error object to true.
-- Append the information on errorinfo to the Error object.
Error. prototype. popStackFrame () method:
-- Organize more elegant and intuitive information (lineNumber, stack) for the Error object)
-- Invalid for IE
-- If a method only returns an Error object instead of throwing an object, you should call this method before returning it.

 
Function native type
Same as Array and String type Processing
Each method is a Function-type instance.
-- Typeof (Array) = typeof (Function) = "function"
This context reference is determined based on the initiated object during method calling.
Funciton. prototype. apply (instance, args)
Function. prototype. call (instance, [arg1, [, arg2, [,...])

Fucntion native type Extension
Function. createDelegage (instance, method) method:
-- Get a method reference. The method is called when the method is executed, and ensure that the context of the method this reference is instance.
Function. createCallback (method, context) method
-- Get a method reference. When the method is executed, the method is called and the context is passed as an additional parameter.

Boolean native type
Use a Boolean value instead of a Boolean object
-- True and false instead of new Boolean (..)
-- (New Boolean (false) & true) = true ??
Boolean native type Extension
Parse static method
-- Boolean. Parse ("true") // true
-- Boolean. Parse ("tRuE") // true

Number native type
32-bit integer or 64-bit floating point number (IEEE754)
Integer notation
-- Var num = 50; // 10 hexadecimal notation
-- Var num = 060; // octal notation value 48
-- Var num = 0xFF // hexadecimal notation value 255
The number obtained by using ParseInt ("09") as 0 is in octal notation.
Use ParseInt ("09", 10) to 9. The second parameter indicates a 10-in-hexadecimal conversion.
Floating point representation
-- Var num = 5.0;
-- Var num = 3.2e9 // 3.2*10 ^ 9, scientific notation
Static attributes
Floating Point Range
-- Number. MAX_VALUE // maximum value
-- Number. MIN_VALUE // minimum value
Extreme Value
-- Number. POSITIVE_INFINITY // positive infinity
-- Number. NEGATIVE_INFINITY // negative infinity
Not a number (not a number)
-- Number. NaN

Number native type Extension
Conversion between numbers and strings

String> Number
-- Number. parseLocale (value)
-- Number. parseInvariant (value)
Number> string
-- Number. prototype. format (format)
-- Number. prototype. localeFormat (format)

LocaleFormat and parseLocale Methods
-- Set the EnableScriptGlobalization attribute to true.
-- Language and Culture set in the browser
-- It can be changed through Page. Culture.
-- Formatting will output to the page
ParseInvariant and format
-- Equivalent to en-US

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.