JAVASCRIPT Conversion String Miscellaneous

Source: Internet
Author: User
Tags bitwise

Number () encounters null is converted to 0, and Underfind is converted to Nan.

General integers are converted to Nan by using the parseint () method, which encounters a null. (Note the difference) The method can set the second parameter parseint ("to convert a string", a few binary). Encountering a decimal point stops parsing, which is ignored later.

Parsefloat () is also parsed from the first character until the end or an invalid floating-point numeric character (the second decimal point) is encountered. The hexadecimal string is always interpreted as 0, only the decimal is parsed, and there is no second argument.

The ToString () method can be called directly without input parameters, and when the ToString () method of a value is called, a parameter can be passed, the cardinality of the output value, the binary to 16 binary, and the decimal by default.

--and + +

When the operator performs a pre-increment and decrement operation before the value is manipulated, the value of the variable is changed before the statement is used for the job.

The post increment and decrement operations are performed after you include their statements evaluated.

Bitwise operator ( What's the use of this thing?) ),

Converts a string into a 32-bit binary code, right-to-left direction, and 32nd digit as a sign. In theory, unsigned is a positive integer, and an unsigned 32nd digit can represent a number instead of a symbol, which theoretically has a larger value.

To find the absolute value of the binary code, to find binary inverse code, the resulting binary anti-code plus one.

Nan and infinity will be treated as a "%".

Bitwise NON (NOT) ~ represents. Operation essence is the negative value of the operation loss minus one.

Bitwise AND (and) &. Only two of the bitwise values are 1 o'clock and 1 is returned, and any 0 result is 0.

A bitwise OR (OR) | representation. One of the bitwise values is 1 and returns 1.

Bitwise XOR or (XOR) ^ represents. Only one of the bitwise values is 1 o'clock returns 1.

Move left << indicate. The right side of the original value has five more seats.

Signed Right shift >> representation (retains sign, starting from 31st), five extra empty on the left side of the original value.

Unsigned right shift >>> representation. unsigned and signed for integers, but different for negative numbers. The unsigned Right shift first fills the empty space with zeros. Instead of being filled with symbols like the right shift of a symbol. The second unsigned right-shift operation treats the binary code of negative numbers as a positive binary code. And because negative numbers are expressed in their absolute twos complement form, this results in a very large result after the unsigned right shift.

Logical NON (! The logical non-operator first converts his operand to a Boolean value and then deserializes it.

Logic and (&&) is a short-circuit operation, that is, the first operand determines the result, then the second operand is no longer evaluated. If the first operand is false, no matter what the second operand is, the result is not likely to be true.

Logic or (| | ) is a short-circuit operator, the first operation evaluates to true, and the second operand is not evaluated. (you can avoid assigning null or underfind to variables)

Multiply sex operator

Multiplication, nothing to say.

Division, 0 by 0 apart from the result is Nan. As long as it is related to infinity (whether positive or negative), the result is infinity plus or minus see operator.

Modulus (that is, to take the remainder)%:

    • If the divisor is an infinite value and the divisor is a finite number, the result is Nan
    • If the divisor is a finite large number and the divisor is zero, the result is Nan
    • If Infinity is infinity, the result is Nan
    • If the divisor is a finite number and the divisor is an infinite number, the result is dividend    

(God horse?) Forget the divisor and divisor relationship? ) Look here:

First you need to figure out the concept of "divide" and "divided". For example: 14 divided by two, the formula listed is "14÷2", and 14 except two, the list is "2÷14", "divide" and "divided" the concept is different.
So the preceding number (14) is the addition of the number (2) in the back, called "dividend". (The list is "14÷2"). "Dividend" is to be "divisor" in addition.
14÷2, read: "14 by 2 divide" or "14 divided by 2".
before that, I had no idea subtraction so many lanes. (Imagine an expression)

  Additive operator, you can use parentheses to tell the parser to calculate its results first. Very useful. In particular, the addition of three strings can be used to add two are numeric strings, finite operations.

All operations, in which the operand is a string, a Boolean, null, or undefined, call the number () function in the background. More of the "" Null value is empty (0).

The relational operator, when comparing strings, actually compares the character encoding value of each character in the corresponding position in the two string. The character encoding for-----uppercase letters is all less than the lowercase character encoding. Therefore, to sort by alphabetical comparison you must convert the case at the same time. When a string is a number, compared to another number, the string is converted to a numeric value, and then the size is compared.

var result = "All" < "3"//true because the encoding of "2" is 50, and "3" is 51.

Equality and inequality: null and undefined are equal. Null and undefined cannot be converted to other values. If the one that is Nan is equal to false, if two are Nan equal or flase. One is that the object calls the ValueOf () method. Null==0//false

If, Do-while, while, for, for-in, break: Exit the loop now, continue: Exit the current loop, continue to the next loop until the end, label can add tags to the code for future use.

Similar to label: for () {Break label;//Return to which label }, with (expression) {statement}, is to simplify the work of writing the same object many times, Deprecated, not allowed in strict mode.

switch is more useful.

JAVASCRIPT Conversion String Miscellaneous

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.