为什么所有JavaScript文档中的参数都是这样写的? [英] Why arguments in all JavaScript Documentation are written like this?

查看:124
本文介绍了为什么所有JavaScript文档中的参数都是这样写的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆