当前位置:网站首页>? 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++]
}
}
边栏推荐
- 基于微信小程序的婚纱影楼门户小程序
- Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
- 活性染料研究:Lumiprobe AF594 NHS 酯,5-异构体
- How to learn programmable logic controller (PLC)?
- 8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
- 禁用右击、键盘打开控制台事件
- 电源插座是如何传输电的?困扰小伙伴这么多年的简单问题
- quartus 复制IP核
- MCLK configuration of Qualcomm platform camera
- Intensive learning notes
猜你喜欢

基于订单流工具,我们能看到什么?

氨基染料研究:Lumiprobe FAM 胺,6-异构体

2022 high altitude installation, maintenance and removal examination questions and answers

Function reentry caused by Keil C51's data overlaying mechanism

Feign implements path escape through custom annotations

CpG solid support research: lumiprobe general CpG type II

Docker安装Mysql5.7并开启binlog

gorm事务体验

Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism

Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
随机推荐
Opencv实现目标检测
2022电力电缆判断题模拟考试平台操作
Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
Performance degradation during dpdk source code testing
lotus v1.16.0 calibnet
【LeetCode】12、整数转罗马数字
Keil C51的Data Overlaying机制导致的函数重入问题
CPG 固体支持物研究:Lumiprobe通用 CPG II 型
现代交换原理MOOC部分题目整理
mysql导出数据库字典成excel文件
活性染料研究:Lumiprobe AF594 NHS 酯,5-异构体
程序员-放羊娃
Study on chemical properties and technology of biovendor rage ELISA Kit
Steve Jobs' speech at Stanford University -- follow your heart
Organize the online cake mall project
Don't roll! How to reproduce a paper with high quality?
Gorm transaction experience
基于订单流工具,我们能看到什么?
MySQL 45讲 | 05 深入浅出索引(下)
[skywalking] learn distributed link tracking skywalking at one go