ES6模块化


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

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

<body>
    <script type="module">

        import { cocktailSort } from './cocktailSort.js';
        import { bubbleSort } from './bubbleSort.js';


        var arr = new Array(10000);
        for (let i = 0; i < 10000; i++) {
            arr[i] = i + 1;
        }

        arr.sort(() => Math.random() - 0.5);



        console.time('bubbleSort');
        bubbleSort(arr);
        console.timeEnd('bubbleSort');

        console.time('cocktailSort');
        cocktailSort(arr);
        console.timeEnd('cocktailSort');




    </script>
</body>

</html>

文章作者: iamfugui
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 iamfugui !
评论
  目录