This is a javascript function assert(value[, message])
.
I want to know what is difference between assert(value[, message])
and assert(value, message)
.
This is a javascript function assert(value[, message])
.
I want to know what is difference between assert(value[, message])
and assert(value, message)
.
The square brackets are used when writing function descriptions to indicate that the parameters are optional.
In the case of assert(value[, message])
the first parameter, value
, is required. If you try to call the function without it -- assert();
-- the function will not work or will throw an error. The second parameter, message
, is optional. You can call the function with just the first parameter -- assert(value);
-- and it will work correctly.
If the function is shown as assert(value, message)
then both parameters are required and they both must be given in order for the function to execute as expected or without throwing an error.