两道js笔试题

两道js笔试题:

var tempb=function(){this.x=1;this.getX=function(){return this.x;}}
var tempn=function(){this.x=2;}
var t=new tempb();
var g=new tempn();
alert(t.getX());

g.getX=t.getX;

alert(g.getX());

g.getX=function(){return t.getX();}

alert(g.getX());

写出执行结果:

var p=12;
var result=(function(x,y,z){
    this.tempx=10;
    if(x<this.tempx){
        return x;
    }else{
        var objb={tempx:11};
        objb.func=z;
        return objb.func(y);
    }
})(p,function(x){return x*x;},function(z){ return z(this.tempx);});

写出执行结果:

原文地址:https://www.cnblogs.com/hongyin163/p/2794968.html