gpt4 book ai didi

javascript - 这是什么/*global $, window : false, document: false */

转载 作者:行者123 更新时间:2023-11-28 13:29:15 25 4
gpt4 key购买 nike

为什么一些 JavaScript 开发人员将这种类型的隐藏代码放在他们的页面顶部?

 /*global $, window: false, document: false */

最佳答案

JSLint also recognizes a /*global*/ directive that can indicate to JSLint that variables used in this file were defined in other files. The directive can contain a comma separated list of names. Each name can optionally be followed by a colon and either true or false, true indicating that the variable may be assigned to by this file, and false indicating that assignment is not allowed (which is the default). The directive respects function scope. Source: http://www.jslint.com/lint.html

根据您的示例,开发人员告诉 JSLint $ 是在其他文件中定义的,windowdocument 是由浏览器定义的并且不允许分配。

关于javascript - 这是什么/*global $, window : false, document: false */,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26413623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com