前端笔试遇到的
以下两个代码输出结果是什么?这两个不太懂,希望有大佬帮助解决!
题目一:
var a = 1; var func = function(a) { a = 2; func2(a); } var func2 = function(a) { a = 3; } func(a); console.log(a); var obj = { val : 1 }; var func3 = function(obj) { obj.val = 2; func4(obj.val); } var func4 = function(val) { val = 3; } func3(obj); console.log(obj);
题目二:
let a =5; class A{ a=10; fn(){ console.log(this.a); } } const b = new A().fn; b(); //报错