I would like to understand the weird behaviour of JavaScript identity and equality operator as given below.
var a = {};
var b = {};
a === b; //false
a == b; //false
var c = '';
var d = '';
c === d; //true
c == d; //true
All four variables a ,b ,c and d are objects. But when comparing them, first case yields false whereas second one true.
I studied comparison from the following source: https://msdn.microsoft.com/en-us/library/d53a7bd4(v=vs.94).aspx
According to the above article, except number and boolean everything is compared by reference instead of value. So how the first case returns false and second one true.
So how the first case returns true and second one false.other way around, first is false, second is truevar c = new String(''), d = new String('');then see how you go