查看这篇文章,了解 ArcGIS 3.0 中的 javascript 代码。https://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0
里面有“if(0)”和“if(1)”,为什么需要这个呢?if(0) 不是总是 false 而 if(1) 总是 true 吗?
是的,0永远是假的,也1永远是真的。
然而,正如您在代码中看到的,该公司认为这是他们的商业秘密:
COPYRIGHT 2009 ESRI
TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
Unpublished material - all rights reserved under the
Copyright Laws of the United States and applicable international
laws, treaties, and conventions.
Run Code Online (Sandbox Code Playgroud)
混淆此类代码(即使其更难以阅读)是很常见的。其中一种方法是插入无用的语句,例如您所看到的if(1)和。if(0)
您可以在此处阅读有关混淆的更多信息。
另一种可能的解释是,if正如 @mvbl fst 提到的,这些语句用于代替尚未实现的实际逻辑。