1、console.log 怎么打印有颜色的字体。
使用占位符%c:
console.log('%c this is color! ', 'background: #222; color: #bada55');
2、“15”+5 的结果是?“15”-5 的结果是?
"155" , 10
3、1 + - + + + - + 1 结果是?
2
4、(function() { var x = y = 1;})(); console.log(x); //结果是?console.log(y);//结果是?
x is not defined
y:1
5、var arr1 = [1,2],arr2=[1,2],arr3 = arr1;
1)、arr1 === arr2; arr1 === arr3 结果是?
false true
2)、[]==[]; [1,2]==[1,2] 结果是?
false false
6、请问 (function(i){ return i || "Tuesday" },"Monday") 的结果是什么?
"Monday"
7、typeof(null) 结果是什么?void(0) 的结果?
object undefined
8、有数组 var arr= [1,2,3],哪些方法可以判断是 Array 类型?
var arr = [1,2,3]; console.log(arr instanceof Array);//true
var arr = [1,2,3]; console.log(arr.constructor === Array);//true
9、
var x="undefined";
var y="false";
var z="";
function assert(xVar){
if(xVar)
console.log(true);
}else {
console.log(false);
}
assert(x);
assert(y);
assert(z);
结果是true true false
xyz加上引号都是字符串。在字符串中空串是假,其他的都是真。所以x y 为非空字符串,转换为true,z 空字符串 转为 false