JavaScript seems to have several different “groups” of functionally similar things. Here are my names for them:
"Regular functions": they are called using parsers and with new . Most features fall into this category.
"Functions only for the constructor": they can only be called with new . For example, Image , DOMParser , etc.
"Non-constructor functions": they are called using parsers, but not with new . For example, Math.round , Function.prototype .
Non-Callable Functions: These functions are not callable at all. For example, window.constructor , Document , NodeList , etc.
What are the name names for these different function groups?
I am also trying to find out if any of the "groups" of the function can be dependent on whether its [[Prototype]] ( __proto__ ) __proto__ to Function.prototype .
Most “ordinary functions” will have Function.prototype , but it can be removed using the non-standard __proto__ .
Most constructor-only functions have Object.prototype . I can not find cases where they have Function.prototype (like no call or apply ). This is always the case: / spec 'd behavior?
Non-constructor functions seem to basically have Function.prototype , with the exception of Function.prototype itself. Are there other cases that have Object.prototype ?
"Non-callable functions" always appear to be Object.prototype . Is this the case?
I will answer some answers here:
Regular Function: function
Constructor: constructor
Unconstructor: method
Non-callable: interface
This is not what I am looking for. "function" and "constructor", of course, are correct in general, but I'm looking for something more specific ("non-constructor function", etc.).
The "method" is no better than the "function", saying that it cannot be called with new , and the constructor does not get a point through which it can only be called with new .
In many cases, functions that cannot be called are available only from the constructor property of the host object. I think that most of them will more accurately be called "constructors" than "interfaces".
[Information about host objects and source objects]
This seems like the right way. Given this question (and the accepted answer and its comments), there seems to be some disagreement or confusion as to whether the user-defined functions are the host or native objects.
To avoid this, let’s just call UDF custom functions and not worry about whether they are the host or the native. So we have UDFs, host objects, and our own objects.
So it seems like there is a relationship between host objects and constructor-only / no-call functions, but host vs native does not seem to apply to non-constructor and regular functions.
Dagg nabbit
source share