Why some see the object that does not exist?

There is a button that checks the array for the presence of the object, if the object is not added to the item.
At the first inspection(when the array is empty) in the array is added to the desired object
But why then when checking it turns out that in the array there is an object that is not there.
5cf7bd0026a23906049783.png5cf7bd08ca21d524120634.png
March 23rd 20 at 19:13
1 answer
March 23rd 20 at 19:15
What do you think of logic must be incorporated into the variable i?

Judging by the code the variable i evaluates to trueif at least one element elemin array cart ,will not equal scope.items
Accordingly, ALMOST ANY newly added element scope.the items array in the cart is not equal to at least ONE that is already in the array => the output you'll get i = true

when i === true code block on lines 58 - 61 will not be performed

Find more questions by tags AngularJavaScript