Deduplication of objects in an array in javascript

Because of the urgent need, I can't find the appropriate code on the Internet, so I wrote it in a short time, and there are inevitably bugs. I hope you forgive me.

var arr1 = [{x:513.4261838440111,y:174},
    {x:270.3404255319149,y:174},
    {x:513.4261838440111,y:174},
    {x:520.5167237931058,y:369.80798782499784},
    {x:520.5167237931058,y:369.80798782499784},
    {x:241.57929926401988,y:381.9650668601638},
    {x:270.3404255319149,y:174},
    {x:241.5792992640199,y:381.9650668601638}
]

for (var i = 0; i < arr1.length - 1; i++) {
    for (var j = 1; j < arr1.length; j++) {
        if (i != j) {
            if (arr1[i].x == arr1[j].x && arr1[i].y == arr1[j].y) {
                arr1.splice(j, 1)
            }
        }

    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326174276&siteId=291194637