Javascript Prototyping Question
        Posted  
        
            by Nick Lowman
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Nick Lowman
        
        
        
        Published on 2010-05-09T21:20:55Z
        Indexed on 
            2010/05/09
            21:28 UTC
        
        
        Read the original article
        Hit count: 301
        
JavaScript
I'm just reading about Prototypes in JavaScript and Douglas Crockford offers and excellent way to select a new objects prototype but can anyone explain (below) why obj01's type equals 'object' when I pass it in function as it's prototype?
if (typeof Object.beget !== 'function') {
     Object.beget = function (o) {
         console.log(typeof o);//function
         var F = function () {};
         F.prototype = o;
         console.log(typeof F);//function
         return new F();
     };
}
var func01 = function(){};
var obj01 = Object.beget(func01);
console.log(typeof obj01);//object
console.log(typeof obj01.prototype);//object
I thought it would be
console.log(typeof obj01);//function
console.log(typeof obj01.prototype);//function
        © Stack Overflow or respective owner