Websocket data push problem, how to compare the differences between the two push results

the background pushes to the front end via WS, similar to [{val="1",...}, {val="2",...},...] For such a piece of data, how does the front end compare the difference between the two pushed data, and locate which attribute value of the specific object has become larger or smaller, for example: the value of the object listed above? it is better to save the result of the last push in that way. I hope you can answer it if you understand it. Thank you!

Apr.19,2022

you can define a variable globally to store the data pushed by ws. Pseudocode:

var global = null
ws.on('event', function (data) {
    if (!global) {
        //  global data
    } 
    // 
    global = data
})
Menu