1 Star 0 Fork 0

aparece/codeql

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
EmptyArrayInit.qhelp 1002 Bytes
一键复制 编辑 原始数据 按行查看 历史
Pavel Avgustinov 提交于 2018-08-03 00:53 +08:00 . QL code and tests for C#/C++/JavaScript.
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Elements of array literal expressions that are omitted will be initialized to <code>undefined</code>.
However, such omitted elements are easy to miss and make code hard to read. They should be avoided.
</p>
</overview>
<recommendation>
<p>
Explicitly initialize the array elements to <code>undefined</code>. If you want to create an array
with a specific number of uninitialized elements, use the <code>Array</code> constructor instead.
</p>
</recommendation>
<example>
<p>
The following code snippet initializes <code>a</code> to an array of size ten by using omitted
elements.
</p>
<sample src="examples/EmptyArrayInit.js" />
<p>
This code is clearly hard to read, and should be replaced by the following snippet:
</p>
<sample src="examples/EmptyArrayInitGood.js" />
</example>
<references>
<li>D. Crockford, <i>JavaScript: The Good Parts</i>, Appendix C.6. O'Reilly, 2008.</li>
</references>
</qhelp>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aparece/codeql.git
git@gitee.com:aparece/codeql.git
aparece
codeql
codeql
main

搜索帮助