I have an array of Plotly traces.
console.log(traces):
traces:
[{…}]
0:
name: "temprature"
type: "scatter"
x: (7523) [1527581340000, …]
y: (7660) [15.68, …]
__proto__: Object
length: 1
__proto__: Array(0)
At an event, I want to check if a newly created trace is on the list or not. Firstly, I check it with the includes function but it didn't work, then I found this answer on how to check the availability of an object in an array in js.
function contains(a, obj) {
        for (var i = 0; i < a.length; i++) {
            if (a[i] === obj) {
                return true;
            }
        }
        return false;
}
but it seems not to work for me.
$("#temprature").change(function () {
        var trace_temprature  = {
                            x: index,
                            y: temprature,
                            name: document.getElementById('temprature').name,
                            type: 'scatter'
        };
        if (document.getElementById('temprature').checked) {
            if( !traces.includes(trace_temprature) ){
                traces.push(trace_temprature);
            }
            console.log('trace in the add ', traces);           
            console.log('temperature trace: ', trace_temprature) // this line prints the same object on the previous list
            
        } else {
            console.log('if condiiton: ', contains(traces, trace_temprature)); // this line print False
            if( contains(traces, trace_temprature) ){
                var ind = traces.indexOf(trace_temprature);
                traces.splice(ind, 1);
            }
        }
      
    });
any ideas?
