which of the following are valid object constructors?
1) var m = function(){}
2) m = function(){}
3) m.prototype.constructor = function(){}
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.
They all appear to be valid statements that declare an empty function, and assign it to different variables.
Every function in Javascript is both an object itself (or f.prototype wouldn’t work) and a potential object constructor. Any function may be called with the
new Thingysyntax (or perhapsnew min your example). Or it could be called normally – the only special thingnewdoes is setthisto an object derived from f.prototype.A newly created function has a
prototypeproperty that contains a newly minted object ({}), which has no properties except a hiddenconstructorproperty pointing at the function (it’s a circular reference, actually)It should be true that: