!function 匿名函数中的变量怎样能在外部获取到?代码:!(function (w) { var a = { itemId:1, adtype:2, device:2
} if (window.adlist) {
w.adlist.push(a);
}
})(window)对方说可以拿到,类似面试题;菜鸟看不懂如何才能在外部拿到里面的a;求大神。
1 回答

智慧大石
TA贡献1946条经验 获得超3个赞
var adlist = []; !(function (w) { var a = { itemId:1, adtype:2, device:2 } if (window.adlist) { w.adlist.push(a); }})(window)console.log(adlist[0]);
添加回答
举报
0/150
提交
取消