JavaScript参数中的中括号

中括号代表 参数可选
举例:

buf.write(string[, offset[, length]][, encoding])

例子中:
第一个参数string没有中括号,意思是必须传的;
offset[, length]]encoding在中括号内,为可选参数,即offset, length, encoding可传可不传;
[, length]外面是offset,意味着没有传offset的话,length也不能传

原文地址:
https://segmentfault.com/q/1010000013052364

猜你喜欢

转载自blog.csdn.net/u011141492/article/details/88546582
今日推荐