当我跑步时
var validValues = [ 10, 20, 23, 27 ];
var statusType = json.properties.status.type;
/* This function call will return a boolean that tells you wether the value in your json is valid or not.*/
isValid( statusType );
function isValid( statusType )
{
for( var i = 0; i < validValues.length; i++ )
if( statusType === validValues[i] )
return true;
return false;
}
或
null == 0
即使两者都是假值,两者都输出错误,为什么?
答案 0 :(得分:-1)
==不仅会检查值,还会检查类型(而不是与===相同) 您可以在此处查看更多详细信息:The Abstract Equality Comparison Algorithm