构造函数返回值问题

来源:互联网 发布:关键字优化 编辑:程序博客网 时间:2024/06/06 08:53
/**         关于构造函数的返回值;          原本以为无论设置返回的东西只返回this, 也就是这个构造对象;         return []; 返回此数组         return {}; 返回此对象         return function; 返回此函数         return 1; 返回this;         return 'a'; 返回this;        return null; 返回this;        return undefined; 返回this;        return this.functionName; 返回此函数;        return this.objectName; 返回此对象;        return this.arrayName; 返回此数组        return this.stringName; 返回this;        return this.numberName; 返回this;        return this.nullName; 返回this;        return this.undefinedName; 返回this;     */         var lang = function(arg){        return undefined;    }    lang.prototype = {        objectName: {},        functionName: function(){},        arrayName: [1,2,3,4],        stringName: 'aaa',        numberName: 1234,        nullName: null,        undefinedName: undefined    }

0 0