从回流角度回答,实际上面试官希望从安全角度回答?
function G() { return ()=> { console.log(this); } } var g = new function G() g() // this指向
<body> <div id="a">a</div> <div id="b">b</div> <div id="c">c</div> </body> #a { position: relative; width:100px; height:100px; } #b { postiton:absolute; width:100px; height:100px; } #c { position: relative; width:100px; height:100px; top: 0; left: 0; }
答案:transform
var a = [1, 2, 3]; var b = a; b[5] = 6;
b = [...a]; b = a.map(item => item); b = [].concat(a);
var name = 'weihui'; (function() { if (typeof name === 'undefined') { var name = 'bigo'; console.log('good' + name); } else { console.log('Hello ' + name); } })()
var arr = []; var obj = {a: 1}; arr.push(obj); console.log(arr); obj.a = 2; console.log(arr); var obj1= obj; obj = {a: 3}; console.log(arr); obj1.a = 4; console.log(arr);