as known in javascript, a function defined as
function somefunc(){
}
is an instance of its constructor Function. But Function itself is a function either which implies the Function is an instance of Function. Is that what they are? Or there is some other relations between them.
Yes, that is exactly what they are. Function is an instance of Function, as are all functions, including constructor functions. This is completely expected and defined by the language specification. All functions also inherit from Object, so the following statements are all true:
new Function() instanceof Function
(function () {}) instanceof Function
new Function() instanceof Object
(function () {}) instanceof Object
Functions can be created using function statements, expressions or the Function constructor. See Function constructor vs function statement.
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