笔试问题记录2

1. 输出结果是:

(true+false)>2+true

结果是:

false

分析:

(true+false)被转换成了(1+0)=1;
1>3为false

2.下述代码的输出结果:

代码:

<script>
	  console.log("1");
	  setTimeout(function(){console.log("2")},0);
	  new Promise(function(resolve,reject){
	  	resolve();
	  	console.log("hehe");
	  }).then(function(){
	  	console.log("then ok");
	  });
	  console.log("end");
  </script>

输出结果为:

1
hehe
end
then ok
2

3.问下列代码的输出结果:

代码:

var a=1;
	 var obj={
	 	a:'hello',
	 	b:{
	 		a:'end',
	 		c:function(){
	 			console.log(this.a)
	 		}
	 	}
	 };
	 obj.b.c();

输出结果为:

end
分析:在这个问题中this会指向距离它最近的,调用它的对象。

4.问题:

代码:

    var a="coocaa";
	var b=a+'';
	console.log(a===b);

结果:

true

5:输出的正确结果:

代码:

(function(){
     
     try{
		throw new Error();
	}catch(x){
		var x=1,y=2;
		console.log(x);
	}
	console.log(x);
	console.log(y);
  	})();

运行结果为:

1
undefined
2
问题分析:try-catch的运行机制

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值