Reading "JavaScript advanced Programming" Note one-basic concepts

Source: Internet
Author: User
Tags hasownproperty

Grammar
    1. Strict mode enables strict mode to add "use strict" above the top of the script or inside the function; Statement.
Data type
  1. typeof

    typeof returns a undifined,boolean,number,string,object,function of six strings, typeof null returns "Object".

  2. There are six types of data: Undefined,null,boolean,number,string,object
  3. Undefined
  4. Null

    Although null is equal to undefined, it is used differently. A variable that holds an object is not assigned, and the variable should be saved to null.

  5. Boolean
    Data type The value converted to true Value converted to False
    Boolean True False
    String Any non-empty string "" (empty string)
    Number Any non-0 numeric value (including infinity) 0 and Nan
    Object Any object Null
    Undefined Without any circumstances Undefined
  6. Number

    Octal notation: The number is added in front of 0, and octal is not valid in strict mode.

    Hexadecimal means: 0x before the number.

    Infinity and-infinity represent positive and negative infinity.

    NaN (non-numeric) is not equal to any number.

  7. String the
    \ n line wrapping
    \ t tabulation
    \b spaces
    \ r carriage return
    \f feed
    \ \ slash
    \ ' single quote
    \ " double quotes
    \xnn one character in hexadecimal nn (where n is 0~f). For example \x41 Represents a
    \unnnn A Unicode character (where n is 0~f) represented in hexadecimal nnnn. For example, \u03a3 means the Greek character σ

    toString () method, which can pass in the cardinality of a parameter, such as binary, num.tostring (2);

    If you do not know if the value to be converted is null or undefined, you can use the string () function, if the value is not null or undefined call the ToString () method, NULL returns "NULL", Undefined returns " Undefined ";

    To convert a value to a string, you can use the  + ""   method;

  8. Object
    Common property methods for object instances
    Constructor Holds the function that is used to create the current object. such as Object ()
    hasOwnProperty (PropertyName) Used to check whether a given property exists in the current object instance (rather than in the prototype of the instance), PropertyName must be specified as a string. such as O.hasownproperty ("name")
    Ispropertyof (Object) Used to check if an incoming object is a prototype of another object
    propertyIsEnumerable (PropertyName) Used to check if the For-in statement can be used to enumerate, PropertyName must be specified as a string.
    Tolocalstring () Returns the string object of the object
    ToString () Returns the string object of the object
    ValueOf () Returns the string, numeric, or Boolean representation of the object, usually the same as the ToString () value
Operator
    1. When a unary plus operator is applied to a non-numeric value, the operand converts the value like the number () transformation function.
    2. Bitwise non-intrinsic: negative value minus 1 for operand
    3. Logic and (&&) operators:

      Returns the second operand if the first is an object

      If the second is an object, the object is returned only if the first operand is true

      Two operands are objects, returns the second operand

      There is an operand that is NULL to return NULL

      There is one operand that Nan returns nan

      There is an operand that is undefined returned undefined

    4. Logic or (| |) Operator

      Returns the first operand if the first operand is an object

      Returns the second operand if the evaluation result of the first operand is false

      If two operands are objects, the first operand is returned

      Returns NULL if all two operands are null

      If two operands are Nan, a nan is returned

      If two operands are undefined, the undefined is returned

      Use logic or this behavior to avoid assigning null or undefined values to variables, such as: var myObject = Prrfferredobject | | Backupobject

Code and notes git address: [Email protected]:mid__summer/pjwd.git

Reading "JavaScript advanced Programming" Note one-basic concepts

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.