为什么所有JavaScript文档中的参数都是这样写的? [英] Why arguments in all JavaScript Documentation are written like this?
问题描述
JSON.stringify(value[, replacer[, space]])
在MDN上,文档表示这样的参数 value [,replacer [,space]]
。其背后的原因是什么?
All over MDN, the documentation represents arguments like this value[, replacer[, space]]
. What is the reason behind it?
方括号的目的是什么?
推荐答案
方括号由很多编程环境,命令行工具和文档用于显示参数是可选的。
Square brackets are used by a lot of programming environments, command line tools and documentation to show that arguments are optional.
双括号表示供应其中一个可选参数不会强制您为其他参数提供一个值。
The double brackets mean that supplying one of the optional arguments doesn't force you to provide a value for the others.
这意味着替换器
是可选的,如果您提供它,空格
是可选的,并且您不能指定空格
而不指定
That means that replacer
is optional, and if you provide it, space
is optional again, and that you can't specify space
without specifying replacer
.
相反:(sample)
This opposed to: (sample)
JSON.stringify(value[, replacer, space])
如果您提供替换器
的值,则需要为空格
提供值。
Where you need to provide a value for space
if you provide a value for replacer
.
这篇关于为什么所有JavaScript文档中的参数都是这样写的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!