Storing an array value into an array value with no repeat value


setInterval(function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
	if (this.readyState == 4 && this.status == 200) {
		var myObj = this.responseText;

};"GET", "http://i have hide this /wifimac", true);

}, 1000);

let array = [];
function snifferOnServer(x) 

    let obj = x.split(']');
    for (let i = 0; i < obj.length; i++) {
        mac = obj[i];
        macIdData = mac.split(",");

        array = [...array, [macIdData]];


So in the program, I am getting a string of values from a server, and it looks like this:


So I have used the split function to separate every set of data.

As you can see, myObj is constantly receiving data, which I need to store in an array so that I can display it on an HTML page later. So after I again split and target ", " now data look like this


And then I started storing values in array = [...array, [macIdData]];

But the problem is that macIdData contains a repeated value, which I don’t want to store in that array. so basically data consist of


So I need to check if Mac is already presented, and if it is, I need to overwrite it at the same position with the updated ttl and status.I tried a lot But I am not able to do it if someone has any solution for this thank you so much

hey , i recomend that you take a look at the ( set object ) in JS , i found it quite helpeful and fast in situations like this .