一些有趣的JS测试题!

这篇博客分享了一系列有趣的JavaScript测试题目,涉及数据类型转换、运算符优先级、逻辑判断等方面,适合提升JavaScript基础和理解能力。通过解答这些题目,读者可以深入理解JS中的一些常见陷阱和特性。
摘要由CSDN通过智能技术生成

一些有趣的JS测试题!

console.log(true + false); 

console.log([, , ,].length); 

console.log([1, 2, 3] + [4, 5, 6]); 

console.log(10, 2);

console.log(!!"lvhanghmm"); 
console.log(!!"") 

console.log(+!![]); 

console.log(+[]); 
console.log(+![]); 
console.log(+!![]); 

console.log(!!!true); 

console.log(true == "true"); 

console.log(010 - 03); // 5
// Octal literals with prefix '0' are not allowed. Use '0o' prefix instead 【不允许使用前缀为“0”的八进制文字。 改用'0o'前缀】

console.log("" - - ""); 
console.log(null + 0); 

console.log(0 / 0); 

console.log(1 / 0 > Math.pow(10, 1000)); 

// console.log(++true)
// console.log(true++)
// SyntaxError: Invalid left-hand side expression in prefix operation【SyntaxError:前缀操作中的左侧表达式无效】

console.log("" - 1); // -1

console.log((null - 0) + "0");

console.log(true + ("true" - 0)); 

console.log(!5 + !5); // 5

console.log(typeof([] + []));

console.log(NaN++); // NaN

console.log(undefined + false); 

console.log(+0 === -0); // true

console.log(- "" + +"1" * null - [,]);

请忽略下面的内容:

【投稿说明】
博客园是面向开发者的知识分享社区,不允许发布任何推广、广告、政治方面的内容。
博客园首页(即网站首页)只能发布原创的、高质量的、能让读者从中学到东西的内容。
如果博文质量不符合首页要求,会被工作人员移出首页,望理解。如有疑问,请联系contact@cnblogs.com。
【投稿说明】
博客园是面向开发者的知识分享社区,不允许发布任何推广、广告、政治方面的内容。
博客园首页(即网站首页)只能发布原创的、高质量的、能让读者从中学到东西的内容。
如果博文质量不符合首页要求,会被工作人员移出首页,望理解。如有疑问,请联系contact@cnblogs.com。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lvhanghmm

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值