函数执行后能找到存在window对象上的属性,但是找不到存在window对象上函数return的值

function Class01( val, pVal,v ) {
            this.val = val; /*实例可直接读写的属性*/
            var pVal = pVal;
            this.getpVal = function () {
                return pVal;
            };
            this.setpVal = function ( v ) {
                pVal = v;
                return this;
            }    
            this.getpVal()
            this.setpVal();
            console.log(this)
        }
        Class01(1,2,9)

this.getpVal 和 this.setpVal在window上没有return的值 是我console的不对吗?

clipboard.png

阅读 1.5k
1 个回答

你想获得什么效果你描述清楚一点
你这个代码很有问题

推荐问题