比如想写一个回调,可以用promise:
function a(){
return new Promise(function(res,rej){
res()
})}
a().then()
但是现在希望代码能直接在浏览器运行,而不是经过webpack(ES6转5).
那么用
var a = function(x){x();}
a(function(){
console.log('回调')})
//↑像这样的写法会不会存在什么问题?比如兼容等等
阿晨1998
烙印99
慕容3067478
随时随地看视频慕课网APP
相关分类