Some little knowledge of JavaScript

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise bitwise operators

Putting external JavaScript files behind your browser can increase your browser's loading speed
Defer= "defer", wait until the browser has finished loading and execute the script, only valid for external script link
Variables defined with var are local variables, omitting Var is a global variable, it is not recommended to declare global variables in local variables, it is difficult to maintain
。。。。。。
There are 5 simple data types in JavaScript, respectively:
"Undefined" is undefined,
NULL is defined as an empty object reference, so the data type it returns is an object.
Boolean value of "Boolean",
"Number",
"String" string,
There is also a complex type of "Object" object, JavaScript data type is dynamic, with TypeOf can return the above 6 types of data

  1. Null and undefined are values equal, but data types are not equal
    The output data type is undefined before the variable is assigned a value
    Null for objects that are not actually saved
    2 Boolean Boolean, this type has only two literal true and false, to convert a value to a Boolean value, you can use the Boolean () function to convert,
    Other data types can also be converted,
  2. Number numeric type, the decimal space is twice times the integer, the recommended use of integers, for the minimum or maximum number can be used in scientific notation "E", to represent.
    The smallest value in JavaScript is saved in Number.min_value, which is 5e-324 in the browser,
    The maximum value is saved in Number.MAX_VALUE, and the values in the browser are 1.7976931348623157e+308.
    Values beyond the JavaScript range are automatically converted to infinity values.
    Want to know if the numeric value is not between them with the isfinite () function, if it returns true, the reverse will return false,
    Nan is a special value, and Nan is not equal to any of the values of the sum, including itself,
    The IsNaN () function can help us determine if the value is numeric, whether it is possible to convert to a numeric value, a function that does not return true, and vice versa.
    There are three functions that can convert a non-numeric value to a value, namely "number ()", "parseint ()", "parsefloat ()",
  3. String string with double or single quotation marks, string with escape sequence
    The Length property can access the lengths of the strings
    The character of a string is immutable and cannot be changed once it is created.
    To convert a value to a string there are two methods, the toString () function, and almost every value has this method,
    But null and undefined do not, is null to return nul, is undefined return undefined
    Binds a value to a string with a + sign and is automatically converted to a string
  4. Object, which is a collection of data and features that can be created with the new operator, and that allows you to add properties and methods to it, with parentheses
    In JavaScript, object is the basis for all objects and has properties and methods.
    。。。。。。
    operator, an operator for manipulating data values, including arithmetic and bitwise operators, relational operators, and equality operators, which can accommodate multiple values,
    The corresponding operator invokes the valueof () or ToString () method of the object.
    One, arithmetic operators
    1. Unary operators, which operate only one value operator,
    Increment and decrement operators, + + and--
    Pre-and post-type, pre-positioned in front of the variable and placed behind the variable
    The unary operator of a predecessor is based on a value of +1 and a value of 1, with precedence, so the entire syntax is considered to be evaluated from left to right
    The increment of the post-type does not change, and the decrement changes, it is on the original minus one, no priority
    2. Unary plus and minus operators, +,-, and mathematics above do not affect the value, the equivalent of positive and negative
    A non-numeric value invokes a method conversion, a Boolean value of true converts bit 1, and a Boolean value of false translates to 0.
    The addition and subtraction operators are the same for non-numeric conversion rules.
    Second, bitwise operator, conversion of the binary value
  5. Bitwise non (not) is represented by the ~, and execution is the inverse of the return value, and, conversely,
  6. The bitwise AND (and) is represented by &, it has two operands, converts the number of operators to binary, the corresponding bit is 1 to return 1,0 returns 0, returns the decimal,
  7. A bitwise OR (or) is represented, it has two operators, converts the number of operators to binary, the corresponding bit is 1 returns 1, one is 1 also returns 1, two is 0, returns 0, returns the decimal,
  8. A bitwise exception or (XOR) in ^ means that it has two operators, converts the number of operators to binary, the corresponding bit has a 1 to return 1, two things 1 or 0, returns 0, returns a decimal,
  9. Shift left (with two less than sign <<) corresponding digits, signed right shift (with two greater than sign >>) corresponding number of digits, unsigned right shift (with three greater than sign >>>), corresponding number of digits
    Three, Boolean operators, a total of three, "non (Not)", "with (and)", "or (OR)"
  10. Logical non (not) use! Represents, can be used for any value, regardless of any data type, it returns a Boolean value, and then negation of the Boolean value, you can use two logical non-operators, the rule is the same,
  11. Logic and (and) with &&, there are two operands, can be used for any type of operand, cannot use undefined value, it is a short-circuit operator, the first can determine the result, will not ask for a second value
  12. Logical OR (OR) with | | Indicates that there are two operands, it is a short-circuit operator, the first evaluates to true, the second is not evaluated,
    Four, multiply sex operator, defined 3 multiplicative operators, multiplication, division, modulo, in the operation of non-numeric, the background will automatically convert the type,
  13. multiplication, denoted by (*), calculates the product of two numbers, and if the operand is not a number, the background is automatically converted to a numeric value
  14. Division, denoted by (/), executes the second operand divided by the first operand, and if the operand is not a numeric value, the background is automatically converted to a numeric value
  15. Modulo, in (%), the operand is a numeric value, the general calculation, the return of the remainder, if the operand is not a value, the background will be automatically converted to a numeric value
    Five, additive operator and decrement operator, +,-
  16. The addition operator, denoted by (+), also converts different data types in the background, operands are numeric, general calculations,
  17. Subtraction operators, denoted by (-), operands are numeric, general calculation,
    Six, relational operator, less than (<), greater than (>), less than Equals (<=), greater than or equal to (>=), for the comparison of two values, will return a Boolean value,
    The relational operators also have corresponding rules, as follows:
  18. If the two operands are numeric, perform a numeric comparison,
  19. If two operands are strings, compare the character encoding values of the two strings
  20. If one operand is a numeric value, the other operand is converted to a numeric value, and the number is compared
  21. If an operand is a Boolean value, convert it to a number, in the comparison
  22. Any one of the operands compared to Nan is false
    Seven, the equality operator, determining whether two variables are equal is a very important operation in programming, two scenarios: 1. Equal and unequal, first converted in the comparison, 2. Congruent and not congruent, compared to not convert
  23. Equality and inequality are used (= =) to indicate that inequality (! =) means that both operators convert first (forced transformation) and then compare their equality,
    When converting different data types, the following rules are followed:
  24. Congruent and not congruent, congruent with (= = =), the non-congruent (!==), their operands are not converted in the case of the return of the Boolean value,
    In order to protect the data type integrity of the code recommended use congruent and not congruent, Keyword ranking query tool please add link description

Some little knowledge of JavaScript

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.