SOURCE

console 命令行工具 X clear

                    
>
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); // 暂停约 1500 毫秒 console.log(Date.now() - t0);
// }
// 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 (let i = 0; i < 5; ++i) {
//     setTimeout(() => { console.log(i) }, 0)
// }

// //-------------------------------------------------------------------
// let undefinedTest
// console.log(undefinedTest === undefined)

// var bool = Boolean(NaN)
// console.log(Number.MAX_VALUE)

// let num = parseInt('0xadc', 16)
// let text = "This is the letter sigma: \u03a3.";
// console.log(num.toString(16))
// let toStringV = undefined
// console.log(String(toStringV))

// let myMultiLineString = 'first line\nsecond line';
// let myMultiLineTemplateLiteral = `first line
//     second line`;
// console.log(myMultiLineTemplateLiteral)

// let secondTemplateLiteral = `
// first line
// second line`;
// console.log(secondTemplateLiteral[0] === '\n'); // true

// let value = 5;
// let exponent = 'second';
// let interpolatedTemplateLiteral = `${value} to the ${exponent} power is ${value * value}`;
// let interpolatedString = value + ' to the ' + exponent + ' power is ' + (value * value);
// console.log(interpolatedTemplateLiteral)
// console.log(interpolatedString)

// let foo1 = {
//     toString: () => {
//         return 'world!'
//     }
// }
// console.log(`hello ${foo1}`)

// let sym = Symbol()
// console.log(typeof sym)


// class Emitter {
//     constructor(max) {
//         this.max = max;
//         this.asyncIdx = 0;
//     }
//     async *[Symbol.asyncIterator]() {
//         while (this.asyncIdx < this.max) {
//             yield new Promise((resolve) => resolve(this.asyncIdx++));
//         }
//     }
// }
// async function asyncCount() {
//     let emitter = new Emitter(5);
//     for await (const x of emitter) {
//         console.log(x);
//     }
// }
// asyncCount();

//-------------------------------------------------------------------

// let divE = document.querySelectorAll('div')
// function leiArray() {
//     let divA = []
//     for (let item of arguments) {
//         divA.push(item)
//     }
//     console.log(divA)

//     let divB = [...arguments]
//     let divC = Array.from(divB)
//     console.log(divC)

//     let divD = [].concat.apply([], arguments)
//     console.log(divD)
// }

// leiArray('', 2, 'ee', 9)

// console.log(3 ** 3)
// console.log('23' < 3)
// console.log('23' < '3')
// console.log(3-'2')
// console.log(3+'2')

// let a1 = {}
// let a2 = new Object()
// console.log(typeof a1)
// console.log(typeof a2)
// console.log(a1 == a2)

// let obc = new Object()
// let obc1 = obc
// obc1.name = 1
// console.log(obc)
//-------------------------------------------------------------------

// let date = new Date()
// let date1 = new Date('3, 28,2021')
// console.log(Date.parse(date))
// console.log(date.toDateString())
// console.log(date1.toUTCString())

// let regS = 's[a]lbert-fengao.sa'
// let pattern2 = new RegExp('\\[a\\]', 'gi')
// let pattern1 = /a/g
// let rel = pattern1.exec(regS)
// console.log(rel.index)
// rel = pattern1.exec(regS)
// console.log(rel.index)
// rel = pattern1.exec(regS)
// console.log(rel.index)
// console.log(rel.valueOf())

// let bool1 = Boolean('0')
// let bool = new Boolean(false)
// console.log(bool == false)
// console.log(bool === false)
// console.log(typeof bool)
// console.log(typeof bool1)

// let array1 = [1,2,3,4] 
// let array2 = array1.map((item)=>{return item*item})
// console.log(array2)

// let a = [1,2,3];
// let b = a.reduce((i, j) => {
//     console.log(i)
//     console.log(j)
//  return i + j;
// }, 0);
// console.log(b) // 6

//-------------------------------------------------------------------
function Animal(name) {
    this.name = name;
    this.sleep = function(){
        console.log(this.name + '正在睡觉');
    }
}
Animal.prototype.eat = function(food){
    console.log(this.name + '正在吃' + food)
}
let aa = new Animal('斐斐')
aa.eat('水果')
aa.sleep()
//原型链继承
let bb = function(){}
bb.prototype = new Animal()
bb.prototype.name = '冯奥'
let cc = new bb()
console.log(cc.name)
cc.eat('猕猴桃')
cc.sleep()
console.log(cc instanceof bb)
console.log(cc instanceof Animal)
console.log(bb instanceof Animal)

//构造函数
function DD(name){
    Animal.call(this);
    this.name = name || '';
}

let dd = new DD('试试')
console.log(dd.name)
// dd.eat('苹果')
dd.sleep()
console.log(dd instanceof DD)
console.log(dd instanceof Animal)

//组合继承
function EE(name){
    Animal.call(this);
    this.name = name || '';
}
EE.prototype = new Animal();
EE.prototype.constructor = EE;
let ee = new EE('纠结');
ee.sleep()
ee.eat('凯凯')
console.log(ee instanceof EE)
console.log(ee instanceof Animal)

//寄生组合继承
function inheritPrototype(sType,pType){
    let prototype = Object(pType.prototype);
    prototype.constructor = sType;
    sType.prototype = prototype;
}
function FF(name){
    Animal.call(this);
    this.name = name || '';
}
inheritPrototype(FF, Animal);

let ff = new FF('哈哈')
ff.eat('菠萝')
ff.sleep()
console.log(ff instanceof FF)
console.log(ff instanceof Animal)
console.log(FF instanceof Animal)

console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
console.log(Math.ceil(Math.random()*9+1))
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>webpack简介</title>
    <!-- <link rel="stylesheet" href="./index.less"> -->
</head>
<body>
    <div class="parent"></div>
    <div class="child"></div>
</body> 
</html>
.parent {
 	position: absolute;
 	width: 300px;
 	height: 300px;
 	margin: auto;
 	top: 0;
 	left: 0;
 	bottom: 0;
 	right: 0;
 	background-color: pink;	/* 方便看效果 */
 }
 .child {
     position: absolute;
     left: 50%;
     top: 50%;
     height: 30px;
     width: 30px;
     background-color: blue;
     transform: translate(-50%,-50%);
 }