数美(sm)面经
Posted nini123123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数美(sm)面经相关的知识,希望对你有一定的参考价值。
1、
console.log(1 && 0)
console.log(0 && 1)
2、
window.val = 1; var json = { val: 10, dbl: function(){ this.val *= 2; } }; json.dbl(); var dbl = json.dbl; dbl(); json.dbl.call(window); alert(window.val + json.val);
3、
var name = ‘Shumei‘; (function(){ if(typeof name === ‘undefined‘){ var name = ‘SM‘; console.log(‘Hello‘ + name); } else { console.log(‘Hello‘ + name); } }) ();
4、
function Test(name, age){ this.name = name; if(age!= undefined){ this.age = age; ? } } ? Test.prototype = { name: "SM", age: 18 }; ? var instance = new Test(); console.log(instance.name); console.log(instance.age); console.log(instance.constructor);
5、
console.log(null == undefined) console.log(Boolean("false")) console.log({} == 0) console.log([] == 0)
6、
var a1 = [1,2]; var a2 = a1; a1[0] = a2[1]; a2.push(3); console.log(a1); console.log(a2);
7、
setTimeout(function(){ console.log(1) }, 0); new Promise(function(resolve, reject){ var i = 0; console.log(2); while(i<100){ i ++ ; i == 1 && resolve(); } console.log(3); }).then(function(){ console.log(4) }); console.log(5);
以上是关于数美(sm)面经的主要内容,如果未能解决你的问题,请参考以下文章