在网上看到一段代码,其中一段如下:
<script>
if (
window.navigator.userAgent.toLowerCase().indexOf("android") > -1 ||
window.navigator.userAgent.toLowerCase().indexOf("iphone") > -1 ||
window.navigator.userAgent.toLowerCase().indexOf("ipad") > -1 ||
"/tradingview" === window.location.pathname
);
else {
document.write('<script src="bkv-sign/modernizr-2.6.2.js"></script>'),
document.write('<script src="bkv-sign/BkavCAPlugin.js"></script>'),
document.write('<script src="bkv-sign/base64.js"></script>'),
document.write('<script src="bkv-sign/xml2json.js"></script>'),
document.write('<script src="bkv-sign/xml2json.min.js"></script>'),
document.write('<script src="bkv-sign/CheckResult.js"></script>'),
document.write('<script src="bkv-sign/XML.js"></script>'),
document.write('<script src="bkv-sign/Utils.js"></script>'),
document.write('<script src="bkv-sign/verify.js"></script>'),
document.write('<script src="bkv-sign/respond.js"></script>'),
document.write('<script src="bkv-sign/CheckPluginValid.js"></script>');
var licenseKey = "";
document.write('<meta name="tokensigning-verification" content="" />'),
document.write('<script src="vntic-sign/tokensigning.js"></script>'),
document.write('<script src="vntic-sign/vnticBase64.js"></script>'),
document.write('<script src="OneSignalSDK.js" async></script>'),
document.write('<script src="lottie.min.js"></script>'),
document.write(
'<script id="oval_custom" src="VNPTBrowserSDKApp.js"></script>'
),
document.write('<script src="jsQR.js"></script>'),
"081" === window.secCodeTheme
? (document.write('<script src="ekyc-web-sdk-2.2.0.2.js"></script>'),
document.write(
'<link rel="stylesheet" href="ekyc-web-sdk-2.2.0.2.css"/>'
))
: (document.write('<scrip src="ekyc-web-sdk-2.2.0.0.js"></script>'),
document.write(
'<link rel="stylesheet" href="ekyc-web-sdk-2.2.0.0.css"/>'
));
}
</script>
我没有看懂,这么长,实际上就一个if else的判断语句,
看里面的else语句,它有很多document.write('');问题是这些document.write('')之间为何用逗号----, 来连接,这样连接了一大窜后,又用逗号来结尾,终结成一个长代码,作者的意图是什么呢?
感觉没啥意图,可能只是分号写错了而已,并且逗号在js里面也能做为分隔符使用,所以这里没报错。
一般在声明变量时使用逗号比较多