var a={
    i:1,
    //valueOf:
    toString:function(){
        if(this.i===1){
            this.i++;
            return 1
        }else{
            return 12
        }
    }
}
if(a==1&&a==12){
    console.log(123)
}

valueOf()方法和toString()方法是一样的,都会在后台进行隐式的调用。

相关文章:

  • 2021-04-18
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-09-24
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2021-12-09
  • 2021-12-05
  • 2022-12-23
相关资源
相似解决方案