function f()
{
}
alert (f.prototype); // returns something like [object Object]
My understanding is by default the prototype of custom function should be null or undefined, can someone shed some light? thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
prototypeproperty of function objects is automatically created, is simply an empty object with the{DontEnum}and{DontDelete}property attributes, you can see how function objects are created in the specification:Pay attention to the steps 9, 10 and 11:
9) Create a new object as would be constructed by the expression
new Object().10) Set the constructor property of Result(9) to F. This property is given attributes
{ DontEnum }.11) Set the prototype property of F to Result(9). This property is given attributes as specified in 15.3.5.2.
You can see that this is true by: