[英]What does function[(thisArg)]) syntax mean?
I'm going through React documentation and got a bit confused of what they trying to say here React.Children.map(children, function[(thisArg)])
when they wrap function argument into square and round brackets simultaneously function[(thisArg)]
.我正在浏览React 文档,当他们将 function 参数同时包装到方括号和圆括号中时,他们试图在这里说什么
React.Children.map(children, function[(thisArg)])
有点困惑function[(thisArg)]
. Can anyone explain the meaning please?谁能解释一下意思吗?
It's meant to mean that .map
accepts an optional third argument, which is the thisArg
to invoke the passed function with.这意味着
.map
接受可选的第三个参数,即thisArg
以调用传递的 function 。 But the syntax given in the documentation is very confusing.但是文档中给出的语法非常混乱。 Put in a more standard way, it would be:
换一种更标准的方式,它将是:
React.Children.map(children, functionToInvoke[, thisArg])
or或者
React.Children.map(children, function(child, index)[, thisArg])
which is how MDN does it , putting the optional argument(s) in square brackets after the required arguments are stated.这就是MDN 的做法,在说明所需的 arguments之后将可选参数放在方括号中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.