Assuming the JavaScript function `doSomething` expects two arguments (`name`, `value`), why will this JS Interop call fail at runtime?
.NET interview question for Advanced practice.
Answer
The anonymous C object is serialized as a single JSON object. The JS function receives one object argument, not two separate arguments (name and value).
Explanation
The C anonymous object data will be serialized into a single JSON object: {"name":"Test","value":123}. The InvokeVoidAsync call passes this single object as the first argument to doSomething. The JavaScript function, however, expects two distinct arguments. name will receive the object, and value will be undefined, which is not the intended behavior.