Huh, so equality isn't transitive in Go. Yikes.
type T int
const a = 0
var b T = a
var c interface{} = b
fmt.Println(a == b, b == c, c == a) // true true false
https://play.golang.org/p/YZ-0Ym5lJ7RIn JS:
false == undefined => false
false == null => false
undefined == null => true a = 1
b = 2
c = 1
a == b => false
b == c => false
a == c => true
Is that surprising? Equality is transitive, inequality is not.Second, if you have to reach for old javascript "features" (or got forbid PHP) to defend a language you're in a bad, bad place.
Third, the broken equality is not something that's usually praised about javascript. In fact the first rule of javascript equality is that there is only one situation in which `==` is the correct operator: checking that something is null (because that avoids having to differentiate between null and undefined, papering over one javascript wart using another). In every other situation you want "strict" (===) equality.
A != B
A != C
B == C
...looks like valid logical statement, ie. A = 1, B = 2, C = 2: 1 != 2
1 != 2
2 == 2 A != B 1 != 2
A != C 1 != 3
B == C 2 == 3JS loose equality is intransitive, though; the standard example being:
'0' == 0; // true
0 == ''; // true
'0' == ''; // false