今天使用百度分享的一段代碼,看到有這么一句(可能是機(jī)器生成的):with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-newDate()/36e5)]奇怪的地方是:with(..)0[];這段,經(jīng)測試:with({a:1,b:2})0[console.log(a)];在控制臺輸出:1undefined如果這樣:with({a:1,b:2})[console.log(a)];在控制臺輸出:1[Object{__exposedProps__={...},toString=function()}]期待有朋友幫忙解釋:with()0[]這段代碼應(yīng)該如何理解的??
關(guān)于javascript一個奇怪的with語法
慕森王
2019-04-13 08:45:56