console
const bubbleSort = (nums) => {
for (var i = 0; i < nums.length - 1; i++) {
for (var j = 0; j < nums.length - 1 - i; j++) {
if (nums[j] > nums[j + 1]) {
let tmp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = tmp;
}
}
}
return nums;
}
const array = [5, 2, 4, 7, 9, 8, 3, 6, 3, 8, 3]
const bArray = bubbleSort(array)
console.log(bArray)
async function foo() {
console.log(2);
console.log(await Promise.resolve(8));
console.log(9);
}
async function bar() {
console.log(4);
console.log(await 6);
console.log(7);
}
console.log(1);
foo();
console.log(3);
bar();
console.log(5);
async function sleep(delay) {
return new Promise((resolve) => setTimeout(resolve, delay));
}
async function foo() {
const t0 = Date.now();
await sleep(1500);
}
foo();
var series = ['a1', 'a3', 'a3', 'a1', 'a5', 'a7', 'a1', 'a3', 'a4', 'a2', 'a1'];
var result= series.reduce(function (accumulator, current) {
if (current in accumulator) {
accumulator[current]++;
}
else {
accumulator[current] = 1;
}
return accumulator;
}, {});
console.log(JSON.stringify(result));
var a = [1, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7];
Array.prototype.duplicate = function() {
return this.reduce(function(cal, cur) {
if(cal.indexOf(cur) === -1) {
cal.push(cur);
}
return cal;
}, [])
}
var newArr = a.duplicate();
console.log(newArr);
for(var i=0; i<5; ++i){}
console.log(i)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>webpack简介</title>
</head>
<body>
<h1 id="tittle">hello webpack</h1>
<div></div>
</body>
</html>
div {
position: absolute;
width: 300px;
height: 300px;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: pink;
}