Shared publicly  - 
 
million dollar JavaScript quiz. what does this return Function.prototype()
19 votes  -  votes visible to Public
{...}
32%
error
11%
undefined
47%
null
11%
something else. comment.
0%
2
Ruslan Berebnev's profile photoXah Lee's profile photoJustin Howe's profile photo
7 comments
 
You're invoking the prototype method without passing any arguments/parameters. It's undefined.
Xah Lee
 
+Justin Howe
Function.prototype is defined by spec to be a function. takes any number of args, returns undefined.

others, e.g. Object.prototype, Array.prototype, are not functions.
 
+Xah Lee I'm not sure I understand the purpose of your reply, other than to provide additional information for those that don't understand, but it was addressed to me. My comment is valid, supported by your explanation. Method = Function.
 
To expand further, it's undefined because you're not calling one of its methods, such as function.prototype.toString(). It is designed to be undefined when not used properly, which is what your example in the OP represented.
Xah Lee
+
1
2
1
 
+Justin Howe yes methods are functions, but in general the value of property key "prototype" are not function themselves. (their properties are often functions)

e.g. Array.prototype is not a function. Calling Array.prototype() is an type error. But Array.prototype.shift is a function.

but the Function.prototype is a special case. It is a function, by spec. However, doesn't do anything useful. e.g.
Function.prototype()
Function.prototype(3)
Function.prototype(3,4)
Function.prototype("xyz")
Function.prototype({})
all returns undefined.

did you know?

i didn't know till yesterday.

 
+Xah Lee I did, and that's what I explained in less detail before your reply here.
Add a comment...