I was going through the code of react-jsonschema-form.I came across following lines which I am unable to comprehend.
var formData = (0, _utils.getDefaultFormState)(schema, props.formData, definitions);
How is content within the first bracket a function to which arguments(schema, props.formData etc.) are passed?
I guess the answer to this question is that in the first expression (0,_utils.getDefaultFormState)
the comma ,
operator evaluates to the last argument and returns it.
So, comma operator operates on it's operands from left to right and returns the last right most evaluated operand in the expression.
But that is different in terms of using functions and its returned values.
// sample from MDN.
function myFunc() {
var x = 0;
return (x += 1, x); // the same as return ++x;
}
As i mentioned in the comment:
First brackets are self executing function and it returns it's value as a function of _utils
object, which accepts 3 or more arguments.
In that context the first parenthesis pair is a sequence of statement whose value is the value of the last expression. Then:
(0,_utils.getDefaultFormState)
returns the function objet _utils.getDefaultFormState
which is then called with the following arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With