Search
Close this search box.

promise 和 prototype 示例

let p1 = new Promise((resolve,reject)=>{
    resolve('123');
})
let p2 = new Promise((resolve,reject)=>{
    resolve('456');
})


async function fun(){
    let a = await p1;
    let b = await p2;
    console.log(a);
    console.log(b);
}

fun();


// let zhou = {
//     a:1,
//     b:2,
//     c:3,
//     biwen:function(){
//         console.log(123);
//     }
// }
// console.log(zhou.a);
// zhou.prototype.zhangsan = function(){
//     console.log('000');
// }

// zhou.zhangsan();


// function Person(a,b,c,d){
//    this.a = a;
//    this.b= b;
//    this.c =c;
//    this.d= d;
// }
// Person.prototype.name = function(){
//     return this.a + '' + this.b;
// }

// const myfather = new Person('zhou','bi','wen','de');

// console.log(myfather.name());



let c1 = new Promise((resolve,reject)=>{
    resolve('第一次登录!');
})
let c2 = new Promise((resolve,reject)=>{
    resolve('第二次登录!');
})

async function z(){
    let aa = await c1;
    let ba = await c2;
    console.log(aa);
    console.log(ba);
}

z();


发表评论

Optimized by WPJAM Basic