带领大家学习javascript基础篇(一)之基本概念(3)

function convertTypeTest(){ var a = ; var b = ""; print ("a:" + a); print ("b:" + b); print ("type of a:" + typeof a); print ("type of b:" + typeof b); print ("a==b:" + (a == b)); print ("a===b:" + (a === b)); print ("a===Number(b):" + (a === Number(b))); print ("String(a)===b:" + (String(a) === b)); print ("type of undefined:" + typeof undefined); print ("type of null:" + typeof null); print ("undefined==null:" + (undefined == null)); print ("undefined===null:" + (undefined === null)); }

  输出结果如下:

a:1 b:1 type of a:number type of b:string a==b:true a===b:false a===Number(b):true String(a)===b:true type of undefined:undefined type of null:object undefined==null:true undefined===null:false

可以很明显看到==和===的区别。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgzdjz.html