我不明白MDN javascript语法文档中所有这些括号的含义。
例如, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
在本文档中,逗号“,”前的每个参数之间都有括号“ [”
Array.prototype.map()
var new_array = arr.map(function callback(currentValue[, index[, array]]) {
// Return element for new_array
}[, thisArg])
Run Code Online (Sandbox Code Playgroud)
但是当我实际编写代码时,
var numbers = [1, 4, 9];
var info = numbers.map(function(num,index) {
return "index: " + index + ", number: " + num;
});
console.log(info)
//output: ["index: 0, number: 1", "index: 1, number: 4", "index: 2, number: 9"]
Run Code Online (Sandbox Code Playgroud)
我不使用数组或在参数中放入[...这些括号在文档中是什么意思?