Basic knowledge of JavaScript is forgotten by oneself _ basics

Source: Internet
Author: User
Tags bitwise bitwise operators numeric numeric value
5%10=5
x= "5" + "5";
x= "5" +5;
document.write (x);(results are:55)

Undefined is the value of an uninitialized variable, without a reference value, which is undefined
var anyway; Anyway is defined to have a null value

Unary operator:delete (delete the reference to the image and method defined by the originator and cannot delete the original ECMAScript method)
The void operator returns undefined to any value

Functions that do not return a value actually return undefined.

A unary addition has no effect on numbers in nature.
A unary addition computes a string in the same way as parseint ()
The difference: only one-dollar addition can be used for:oxb﹑010 and 16-way strings (such as the following).

A unary subtraction calculation string that converts a string to an approximate number and then the value is negative

There are two types of ECMAScript integers: signed integers and unsigned integers

0 for positive numbers and 1 for negative numbers
Positive numbers are stored in true binary form
Negative numbers are also stored as binary code, using binary complement.
To compute the digital binary complement: absolute value is reversed plus one

When working with signed integers, the developer cannot access 31 bits.

var inum =-18;
Alert (inum.tostring (2));
Output is "-10010", not binary complement, in order to avoid the interview 31-bit

The numeric range of unsigned integers is 0 to 4294967295.
After the unsigned integers are converted to strings, only their valid bits are returned.

Bitwise operation NOT (~), bitwise operation and, Bitwise operation OR (|), unsigned Right shift operation (>>>)
Left-shift Operations (<<) Note: Left-shift operation preserves the sign bit of a number
Bitwise operation XOR is represented by a symbol (^)
Only one digit is stored at 1 o'clock, and it returns 1.
All integer literals are stored by default as signed integers.
Only ECMAScript bitwise operators can create unsigned integers.

var iNum1 = 25; 25 equals 00000000000000000000000000011001.
var iNum2 = ~inum1; Convert to 11111111111111111111111111100110
alert (INUM2); Output "-26"

<!--//--> to deal with old browsers
/*/multi-line Comment

The logical NOT operator behaves as follows:
* If the OP count is number 0, return True
* If the OP count is any number other than 0, return false
* If the OP count is null, return True
* If the OP count is NaN, return True
* If the OP count is undefined, there's a mistake.
!! sblue, the first not operator returns a Boolean value. The second not will be negative for this boolean value

The logical AND operation does not necessarily return a Boolean value:
* If one of the operands is an object and the other is a Boolean value, return the object.
* If two operands are objects, the second object is returned.
* If a shipment count is NULL, return NULL.
* If a shipping count is Nan, return nan.

Similar to the logical AND operator, a logical OR operation does not necessarily return a Boolean value if one of the operands is not a Boolean:
* If one of the operands is an object and the other is a Boolean value, return the object.
* If two operands are objects, the first object is returned.
* If a shipment count is NULL, return NULL.
* If a shipping count is Nan, return nan.

Multiplication operator (*)
* If the result is too large or too small, the resulting result is Infinity or-infinity.
* If a shipping count is Nan, the result is Nan.
* Infinity times 0, and the result is NaN.
* Infinity multiplied by any number other than 0, the result is Infinity or-infinity.
* Infinity times Infinity, the result is Infinity.

Division operator (/)
* If a shipping count is Nan, the result is Nan.
* Infinity is Infinity and the result is NaN.
* Infinity is removed by any number and the result is Infinity.
* 0 The result is NaN, except for a number that is not infinitely large.
* Infinity is removed by any number other than 0 and the result is Infinity or-infinity.

Modulo operator (%)
* If the divisor is Infinity, or the divisor is 0, the result is NaN.
* Infinity is Infinity and the result is NaN.
* If the divisor is infinitely large, the result is dividend.
* If the divisor is 0, the result is 0.

var bresult = "< 3";
Two operands are strings, so compare their character codes, "2" character code is 50, "3" character code is 51
var bresult = "< 3";
The string "25" will be converted to the number 25 and then compared to the number 3
Any relational operators that contain NaN are returned False ("a" <15,a parseint () returns Nan)

Equal and non-equals are used to process the original values (before converting to numerical values), and the full and non-equal equals are used to process objects
The rules for performing type conversions are as follows:
* If an operand is a Boolean value, convert it to a numeric value before checking for equality. False to 0,true to 1 (true!= 2)
* If one operand is a string and the other is a number, try converting the string to a number before checking for equality. ("5" = = 5)
* If one of the operands is an object and the other is a string, try to convert the object to a string before checking for equality.
* If one of the operands is an object and the other is a number, try converting the object to a number before checking for equality.
Observe the following rules:
* Value null and undefined equal.
* You cannot convert null and undefined to other values when checking for equality. (Undefined!= 0,null!= 0)
* If a shipping count is NaN, the equal sign returns false, and a non-equal sign returns TRUE. (NaN!=nan)
* If two operands are objects, then the reference values are compared. If two operands point to the same object, the equal sign returns TRUE, otherwise the two operands are unequal.

Full Equals and non-full equals (do not perform type conversions)
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.