Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

JS5003: Cannot assign to a function result

The code attempts to assign a value to a function result. The result of a function can be assigned to a variable, but it cannot be used as a variable. If you want to assign a new value to the function itself, omit the parentheses (the function call operator).

To correct this error

  1. Do not use the value of a function call result as something you can assign to. You can assign the result of the function call to a variable, though.

    myVar = myFunction(42);
  2. Alternatively, you can assign the function itself (and not its return value) to a variable.

    myFunction = new Function("return 42;");

Community Additions

© 2015 Microsoft