标签:Nero console timeout ret fun time efi 函数 class
第一题 var product = ‘apple‘; var obj = { produc:‘pen‘, prop:{ product:‘apple pen‘, getProduct:function(){ return this.product; } } } product=‘pineapple‘; console.log(obj.prop.getProduct()); var buy = obj.prop.getProduct; console.log(buy()); ======执行结果为 =========================apple pen =========================pineapple 第二题 考察箭头函数 window.name = ‘A‘ const obj = { name:‘B‘, getName:()=>{ console.log(this.name); console.log(this); } } const fn = obj.getName; fn(); obj.getName(); fn.call({name:‘c‘}) =====================执行结果为 A A A 第三题 考察arguments对象里是实参值 function test(a,b){ console.log(arguments) return arguments+b+arguments[2]; } var result = test(‘a‘,‘b‘,‘c‘,‘d‘); console.log(result) 第四题 var a = { x:1 }; var b = a; a = a.x={x:1}; console.log(a) console.log(b) // ====================执行结果为 // Object{x:1}; // Object{x:{x:1}} 第五题 var num = 1; function myFunc(){ alert(num); //undefined var num =2; alert(num); // 2 } myFunc(); 第六题 var v1 = ‘global‘; var f1 = function(){ console.log(v1); }; f1(); //global var f2 = function(){ var v1 = ‘local‘; f1(); }; f2(); //global 第七题 ?? var name = "global"; var obj = { name:"local", foo:function(){ this.name = ‘foo‘; }.bind(window) }; var bar = new obj.foo(); setTimeout(function(){ console.log(window.name) //global },0) console.log(bar.name); //foo var bar3=bar2=bar; bar2.name = ‘foo2‘; console.log(bar3.name); //foo2 第八题 题目有问题 var objName = " name1"; function obj(){ var objName = " name2"; funciton innerObj(){ alert(objName); } innerObj(); } alert(obj()); 第九题 window.a = 300; function fn1(){ this.a = 100; this.b = 200; return function(){ alert(this.a) }.call(arguments[0]); } function fn2(){ this.a = new fn1(); } var a = new fn1().b; var v = new fn1(fn2()); 分别弹出 300 200 [object Object] 第十题 ?? function Dog(){} Dog.prototype = { bark(){ console.log(1) } } const dog = new Dog() dog.bark() Dog.prototype = { bark(){ console.log(2) } } dog.bark() Dog.prototype = { bark(){ console.log(3) } } dog.bark() 输出三个 1 第十题 let num = 10; let output = ‘‘; for(let i=1;i<=num;i++){ let sqRoot = Math.sqrt(i); if(Math.floor(sqRoot)!==sqRoot){ continue; } output+=i+‘‘; } console.log(output); 第十一题 const name =‘name‘; const test = `${name}`"${name}"`${name}`; console.log(test); const name = ‘name‘; const test = {name}; console.log(test) 第十二题 "use strict"; a = 1; var a = 2; console.log(window.a); //2 console.log(a); //2 第十三题 var {a,b,c}={"c":10,"b":9,"a":8} console.log(a) //8 console.log(b) //9 console.log(c) //10 第十四题 console.log(NaN==false) //false console.log(!NaN==false) //false console.log(!!NaN==false) //true console.log(NaN==true) //false console.log(!NaN==true) //true console.log(!!NaN==true) //false // 第十五题 function test(a,b){ return a+b+arguments[2]; } var result = test("a","b","c","d") console.log(result); //abc 第十六题 var a = new Date(2020,3,8) console.log(a) // Date Wed Apr 08 2020 00:00:00 GMT+0800 (中国标准时间)
标签:Nero console timeout ret fun time efi 函数 class
原文地址:https://www.cnblogs.com/princeness/p/11664863.html