0

Why [] symbols are used in parameters of general notation of any thing in JavaScript for eg 'new RegExp(pattern[, flags])'??

Another example 'Date.UTC(year[, month[, day[, hour[, minute[, second[, millisecond]]]]]])' its an example from MDN page. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC

15th May 2020, 7:01 AM
Utkarsh Dhiman
Utkarsh Dhiman - avatar
1 Odpowiedź
+ 2
It is telling you that the parameter(s) within the '[' and ']' is/are optional, meaning you don't necessarily provide any argument for it/them, and the method/function can and will still work, with a defaulted behaviour of course.
15th May 2020, 7:10 AM
Ipang