JavaScript Advanced Programming (Third Edition) Learning notes (2)

Source: Internet
Author: User

Chapter III Basic Concepts

1, Strict mode: The ES3 in the uncertainty of the behavior to deal with some unsafe operation throws an error. To enable strict mode throughout the script, you can add "use strict" at the top and "use strict" at the top of the function to enable strict mode in the function.

2. Define variables: There are var=> local variables; omit var=> global variables. A variable named eval or arguments cannot be defined in strict mode, or it will result in a syntax error.

3. The return value of the TypeOf operator is 6: Undefined, Boolean, string, number, object, function.

4, the detection array can not be used typeof (return object), three ways:

    • ary instance of Array
    • Prototype chain
    • Object.prototype.toString.call (ary)

5, undefined (value: undefined), uninitialized variable value is undefined; Null (value: null).

6, for undeclared variables can only perform a unique operation typeof, and the return value is undefined; The typeof operation return value for an uninitialized variable is also undefined.

7. Type of number: expressed in IEEE754 format.

    • Infinity: Infinity, beyond the JS value range.
    • Nan (not a number):(1) Any value divided by a non-numeric value returns Nan; (2) Nan==nan = false; (3) IsNaN (a) = True:a is not a value (the first attempt is to convert a to a numeric value).

8. Number ()

    • Boolean = 0 (false) or 1 (true)
    • Value = value
    • Null=>null
    • Undefined=>nan
    • String: (1) contains only numbers (including +-numbers), to decimal (ignoring leading 0), (2) a valid floating-point format (with only one decimal), a floating-point value (ignoring leading 0), (3) a valid hexadecimal format, a decimal, (4) an empty string to 0, and (5) in addition, Convert to Nan
    • Object: The ValueOf () method is called first and then converted according to the previous rule, and if the result is Nan, the ToString () method of the object is called and then converted as described above.

9, parseint ():string=> integer

    • Find first non-whitespace string
    • If the first character is not a number or '-' =>nan
    • If the first character is a numeric character or '-', continue parsing, knowing that the first non-numeric character is encountered.
    • parseint ("") =>nan
    • The second parameter represents the cardinality of the transformation

10, parsefloat () similar to parseint (), the first decimal point is valid, the other is not valid.

11. String type

    • Once a string is created, their value cannot be changed (first destroyed and then populated)
    • Three ways to convert a string: (1) a.tostring (); (2) String (a); (3) A + ""
    • ToString (): (1) parameter: Pass cardinality; (2) Undefined and null no ToString () method
    • String (): (1) If the parameter has the ToString () method, call the method (no parameter) and return the corresponding result; (2) If the argument is null=>null; (3) If the parameter is undefined=>undefined

12. Each instance of object has the following properties and methods

    • Constructor: Holds the function that is used to create the current object.
    • hasOwnProperty (PropertyName): Used to detect whether a given property exists in the current object instance (not the prototype of the instance), where PropertyName must be a string.
    • isPrototypeOf (object): Used to check whether an incoming object is a prototype of the current object.
    • Properisenumerable (PropertyName): Used to check whether a given property can be enumerated using the For-in statement, where PropertyName must be a string.
    • Tolocalstring (): Returns the string representation of the object in relation to the execution environment.
    • ToString (): Returns the string representation of the object.
    • ValueOf (): Returns the string, numeric, or Boolean representation of an object (usually the same as the return value of the ToString () method).

JavaScript Advanced Programming (Third Edition) Learning notes (2)

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.