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
热门推荐
1 泰迪狗狗如何训练
3 狗狗训练图
5 狗狗训练方法
6 训练狗狗不咬人
8 敏捷训练狗狗
10 训练狗狗吃饭
11 泰迪狗狗训练
12 狗狗从多大开始训练
13 狗狗训练学校费用
14 怎么去训练狗狗
15 狗狗训练狗狗
16 狗狗训练教程
17 训练狗狗装死
18 泰迪狗狗的训练方法