Today I bumped exactly into this issue: Uncaught TypeError: (intermediate value)(...) is not a function
So yeah, after placing the semicolon where appropriate, it no longer throws that error. However, I never knew there is such a concept in JavaScript (intermediate value)
.
Apparently you can generate a similar variation of that error with this piece of code:
[myFunc] = function(someVar){
console.log(someVar);
return 7;
}();
//error thrown: (intermediate value) is not a function or its return value is not iterable
And if you name the function, it's no longer intermediate
:
function hi(){return undefined}
[a] = hi();
// error thrown: hi is not a function or its return value is not iterable
I understand that it refers to something that is intermediate, but in this case we have an anonymous function, and there are ways to determine if a function is anonymous, so the error message could've been a little more explicit.
Searching the js mozilla mdn I found this page that talks about Array.from
, where the concept of "intermediate array" can be found:
More clearly,
Array.from(obj, mapFn, thisArg)
has the same result asArray.from(obj).map(mapFn, thisArg)
, except that it does not create an intermediate array.
But besides pieces of info here and there, it's not clear what an intermediate value is.
Is there an official definition to this?