js回调封装

一个简单的封装,js回调封装

// 一个简单的封装
function want() {
    console.log('这是你想要执行的代码');
}

function fn(want) {
    console.log('这里表示执行了一大堆各种代码');

    // 其他代码执行完毕,最后执行回调函数
    want && want();
}

fn(want);

 

posted @ 2019-12-10 15:16  wxid_m2pywu7fxu1f  阅读(587)  评论(0编辑  收藏  举报