03JavaScript programming practicing the Road 2019-06-04_fe-js-044es6 array assignment deconstruction deconstruction _2019-06-06_20-10-17 destructuring assignment, array sorting method

 

27array6.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //Analytical destructuring assignment array structure or object extracting different variable values 
        // var name = "Along"; 
        // var Age = 32; 
        var [name, Age]   = [ " Along " , 32 ]; 
        the console.log (name ); 
        the console.log (Age); 
        // var [X, Y, Z] = [. 1, [2.2, 2.3]]; 
        // var [X, [Y, Z]] = [. 1, [2.2, 2.3 ]]; 
        // the console.log (X, Y, Z); //. 1 [2.2, 2.3] undefined 
        var [JSON, ARR, NUM] = [{A: 10 , B: 20 is }, [ . 1 , 2 , . 3 ], 10 ]; 

        var [X ,, =4 ]   = [ 1 , 2 ]; // Default pass 
        console.log (x); 
        var [X, Y ...] = [ 10 , 20 is , 30 , 40 ]; // residual term 
        console.log (x , Y); // 10 [20,30,40] 

        var ARR = [ . 1 , 2 , . 3 ];
         var [... of arr1] = ARR; // clone array 
        the console.log (of arr1); 

        var X   =  10 , the y- = 20;
        /*
        var temp = x;
        x = y;
        y = temp;
        */
        [x,y] = [y,x];
        console.log(x,y);
     </script>
</body>
</html>

27array7.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <arrwas>script
        = [ 12 , 5 , 4 , 6 , 11 , 9 ];
         / * ascending 
          bubble sort 
           12,5,4,6 
           obtained maximum of the first round Comparative 3 
           5 4 12 6 
           5 4 12 6 
           5 4 12 6 
           of two 546 Comparative 2 times to obtain a second value larger 
           . 4. 5. 6 12 is   
           . 4. 5. 6 12 is 
           the third round of Comparative 1 to obtain a third value larger 
           . 4. 5 
 
            ij of 
            0. 3 0 1 ~ 1 ~. 3 ~ 2 2 
            1 2 ~. 1 ~ 2. 1 0 
            .. arr.length. 1-I- 

        * /

        the console.log (bubbleSort (ARR)); 

        function bubbleSort (ARR) {
             // definition of the number of cycles of the control wheel 
            var TEMP =  0 ;
             for ( var I =  0 ; I < arr.length -  . 1 ; I ++ ) {
                 // comparing each of a number of times. 1 2 0 
                for (J =  0 ; J < arr.length -  . 1  - I; J ++ ) {
                     // two adjacent numbers Comparative 
                    IF (ARR [J] <ARR [J +  . 1 ]) {
                         / * 
                        TEMP = ARR [J]; 
                        ARR [J] = ARR [J +. 1]; 
                        ARR [J +. 1] = TEMP; 
                        * / 
                        [ARR [J], ARR [J + . 1 ]] = [ARR [J + . 1 ], ARR [J]]; 
                    } 
                } 
            } 
            return ARR; 
        } 

          // selection sort 
          / * ascending 
            12,5,4,6 
            . 5. 4. 6 12 is 
            . 4 12 is. 5. 6 

            
          * / 
    < / Script >
</body>

</html>

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/HiJackykun/p/11140964.html
Recommended