Strictly uguale (o ===
) significa che il vostro stanno confrontando esattamente lo stesso oggetto a se stesso:
var myObj = {
testProperty: 'testValue'
};
var anotherReference = myObj;
expect(myObj).to.equal(anotherReference); // The same object, only referenced by another variable
expect(myObj).to.not.equal({testProperty: 'testValue'}); // Even though it has the same property and value, it is not exactly the same object
profondamente Pari d'altra parte significa che ogni proprietà del rispetto oggetti (e possibili oggetti collegati in profondità) hanno lo stesso valore. Quindi:
var myObject = {
testProperty: 'testValue',
deepObj: {
deepTestProperty: 'deepTestValue'
}
}
var anotherObject = {
testProperty: 'testValue',
deepObj: {
deepTestProperty: 'deepTestValue'
}
}
var myOtherReference = myObject;
expect(myObject).to.eql(anotherObject); // is true as all properties are the same, even the inner object (deep) one
expect(myObject).to.eql(myOtherReference) // is still also true for the same reason
Eventuali duplicati di [? Qual è la differenza tra pari ?, eql ?, ===, e ==] (http://stackoverflow.com/questions/7156955/whats-the-difference- tra-uguale-eql-e) – 8protons