JavaScript中==和===运算符之间的区别
在JavaScript中,双精度和三重等于用于两个操作数之间的比较。两者之间的区别是:
DoubleequalsnamedasEqualityOperator.DoubleequalsusedasTypeconvertingtheconversionDoubleequalshassyntaxforcomparisonas(a==b)Doubleequalsfirstconverttheoperandsintothesametypeandthencomparei.ecomparisonwouldperformonceboththeoperandsareofthesametype.Thisisalsoknownastypecoercioncomparison.==vs===的示例
Equals.jsp
var a = true; var b = 1; var c = true; console.log (a == b); // first convert 1 into boolean true then compare console.log (a === c); // both are of same type no conversion required simple compare. console.log (a === b); // no conversion performed and type of both operands are not of same type so expected result is false.
输出结果
true true false
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短