河南网站建设公/搜索引擎技巧
==(等同)
首先会去判断两者的类型是否相等,类型不相等则隐式的进行转成相同类型再去比较两者的值是否相同;
===(恒等于,严格等于)
首先比较两者的类型是否相同,当类型不同时,直接返回false;当类型相同后,才去比较两者的值是否相同;
typeof(_this.query(_this.newday))=='object'
//_this.query(_this.newday)是为对象类型object的
以上,类型不等,'object’会先转化成类型object,再去比较两者是否相等,现在是object==object,结果为true;
再比如 "1"==true;
true也可以用1表示,所以现在是"1"1,然后再把1转换成 “1”,所以11,故返回true;
for (let i = 1; i < 60; i++) {_this.newday = _this.subDate(i)console.log("获取到的时间为:" + _this.newday);// _this.query("2020-10-19")// console.log("获取到的数据:" + JSON.stringify(typeof(_this.query(_this.newday))));// console.log(JSON.stringify(typeof(_this.query(_this.newday))));//==:当类型不一致时,会隐式转换成相同类型,再进行比较;//===:先判断类型是否相同,相同才去判断值,类型不同直接falseif(typeof(_this.query(_this.newday))=='object'){console.log("等于")return;}
}
// _this.query("2020-10-30")