<javascript-based Programming > Notes 2015-9-25

Source: Internet
Author: User
Tags bitwise operators

1. One dollar plus minus

    var a=28;            Alert (--a);      // 27, first minus after use    alert (a--);      // 27, first use and then minus    alert (a);        // ,

2. Bitwise operators

Bitwise NON (NOT): bitwise reversed; symbol: ~;

Bitwise AND (and): symbol:&;

bitwise OR (OR): symbol: |;

Bitwise XOR (XOR): symbol: ^; the same value is 0, different bit value is 1;

Shift left: Symbol:<<; moves all the bits to the left,

var oldvalue=2;    var newvalue=oldvalue<<5; After moving left, the original position is padded with 0,

Signed right Shift: symbol:>>; This action shifts the value to the right, but leaves the symbol bit on the left,

Unsigned right Shift: symbol:>>>; This operator moves all 32 bits of a value to the right.

3. Boolean operators:

Logical non: operator:!

Logic and: operator:&&

Logical OR: operator: | |

4. Subtraction:

Add:

var result=5+ "5"; alert (result);         // "", /* If there is a numeric value that is a string, the second operand is converted to a string, then a string is concatenated, and if there is an operand that is an object, a numeric value, or a Boolean, call their ToString () method to get the corresponding string, and then apply the string to the rule. For undefined and null, the string () function is called separately and the strings "undefined" and "null" are obtained. */

Reducing

5.for in statement

The for in statement is a precise iteration statement that can be used to enumerate the properties of an object,

for (var in window)    // loop to display the properties of the Window object {    document.write ( propname);}

However, if the variable value of the object being iterated is null or the undefined,for in statement throws an error,

6.label statements

The label statement is a written format: label:statement;

Start:for (var i=0;i<count;i++) {  alert (i);  }        

To work with continue and break statements:

var num=0; outermost:for (var i=0;i<10;i++) {  for (  var j=0;j<10;j++) {        if(i==5&&j==5)            (break outermost;)            num+ +;    }  } alert (num);         // 55,break not only exits the internal for loop, but also exits the external for loop,

On the program if the break is replaced by continue, the loop is enforced, the exit is not looped, and the external for statement is looped, resulting in 95.

7.with statement: The WITH statement restricts the scope of a piece of code to a specific object,

The WITH statement cannot be used in strict mode and will error.

/*   */

8. Functions

function functionname (Argument1,argument2,...) {    statements;}     // it can be called by its function name, followed by a stack of parentheses and arguments (if there are multiple arguments, you can separate them with commas). 

9.arguments:

The parameters in the ECMAScript are represented internally by an array, and the function receives the array, not the parameters contained in the array.

In fact, the arguments object is just like an array, not an instance of an array, because each of his elements can be accessed using square brackets (arguments[0]).

/*     The Parameter object in the JavaScript function arguments is an object, not an array. But it can access the elements in a table like an array, and it also has the number of elements that the length property identifies. */

10. Overloading.

If two functions with the same name are defined in ECMAScript, then the name belongs to the post-defined function

function addnum (num) {    return num+100;} function addnum (num) {    return num+200;} var result=addnum (+);        // 300, the function defined later overrides the first defined function,

<javascript-based Programming > Notes 2015-9-25

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.