当前位置:网站首页>? How to write the position to output true
? How to write the position to output true
2022-06-28 05:19:00 【Zhangshao】
var a = ?;
console.log(
a == 1 &&
a == 2 &&
a == 3
)
Examination site :== The operation rules of operators , Rules for type conversion 
var obj = {
};
console.log(obj.valueOf()) //{} Non primitive type
console.log(obj.toString()) //'[object Object]'
therefore
obj == 1 //false
obj == '[object Object]' // true
var obj = {
valueOf: function() {
return 1
}
};
obj == 1 //true
So the positive solution is
a = {
n: 1,
valueOf: function(){
return this.n++
}
}
Change questions : console.log(a == 1 &&a == 2 &&a == 4)
a = {
n: [1,2,4],
i:0,
valueOf: function(){
return this.n[this.i++]
}
}
边栏推荐
- Quartus replication IP core
- C语言中函数是什么?编程中的函数与数学中的函数区别?理解编程语言中的函数
- Latest Windows version 5.0.14 of redis
- 109. simple chat room 12: realize client-side one-to-one chat
- 分享一个因子挖掘的利器:遗传规划
- The heading angle of sliceplane is the same as that of math Corresponding transformation relation of atan2 (y, x)
- 并发之wait/notify说明
- 【JVM】——JVM中内存划分
- The latest examination questions and answers for the eight members (standard members) of Liaoning architecture in 2022
- msa.h:没有那个文件或目录
猜你喜欢

短视频本地生活版块成为热门,如何把握新的风口机遇?

Have you finished the examination of level II cost engineer? There are also qualification regulations!

!‘ Cat 'is not an internal or external command, nor is it a runnable program or batch file.

cgo+gSoap+onvif学习总结:8、arm平台交叉编译运行及常见问题总结

The short video local life section has become popular. How to grasp the new opportunities?

JS text box loses focus to modify width text and symbols

Docker安装Mysql5.7并开启binlog

并发之wait/notify说明

如何学习可编程逻辑控制器(PLC)?

2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
随机推荐
Opencv实现目标检测
MCLK configuration of Qualcomm platform camera
刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
2022 high altitude installation, maintenance and removal examination questions and answers
Study on chemical properties and technology of biovendor rage ELISA Kit
学习太极创客 — MQTT 第二章(六)MQTT 遗嘱
metaRTC5.0 API编程指南(一)
Rxswift -- (1) create a project
Redis 的 最新windows 版本 5.0.14
cgo+gSoap+onvif学习总结:8、arm平台交叉编译运行及常见问题总结
如何从零设计一款牛逼的高并发架构(建议收藏)
Pcr/qpcr research: lumiprobe dsgreen is used for real-time PCR
创新之源 理解通透 二
Programmer - Shepherd
gsap的简单用法
The short video local life section has become popular. How to grasp the new opportunities?
Metartc5.0 API programming guide (I)
lotus v1.16.0 calibnet
Keil C51的Data Overlaying机制导致的函数重入问题
Operation of simulated examination platform of G3 boiler water treatment recurrent training question bank in 2022