Home » Javascript » How to remove repeated points from array?

How to remove repeated points from array?

Posted by: admin June 30, 2018 Leave a comment

Questions:

I have this array of points:

0:Point {X: 181708.79357001217, Y: 659243.26713151, rotate: ƒ, move: ƒ, resize: ƒ, …}
1:Point {X: 182534.29357001217, Y: 657010.1837981766, rotate: ƒ, move: ƒ, resize: ƒ, …}
2:Point {X: 186545.37690334552, Y: 660957.76713151, rotate: ƒ, move: ƒ, resize: ƒ, …}
3:Point {X: 181708.79357001217, Y: 659243.26713151,rotate: ƒ, move: ƒ, resize: ƒ, …}

I need to remove the points that have same coordinates.

For example point with index 0 and 3 have the same coordinate. so after I remove it expect to get this array:

0:Point {X: 181708.79357001217, Y: 659243.26713151, rotate: ƒ, move: ƒ, resize: ƒ, …}
1:Point {X: 182534.29357001217, Y: 657010.1837981766, rotate: ƒ, move: ƒ, resize: ƒ, …}
2:Point {X: 186545.37690334552, Y: 660957.76713151, rotate: ƒ, move: ƒ, resize: ƒ, …}

So my question how can I remove repeated points from aary using javascript only?

Answers: