JS功能更紧凑

时间:2020-06-25 17:30:35

标签: javascript

我有一个使用坐标的函数,

我正在寻找一种拥有DRY代码的方式

这是我的代码的一部分: https://codepen.io/sebastiancz/pen/LYGLXjW?editors=1010

一部分是我的代码


 const coordinate = {"x": x, "y": y};
                this.tilesCoordinates.push(coordinate);
                const max = this.tilesCoordinates.length - 1;
                const curr = this.tilesCoordinates[max];
                const prev = this.tilesCoordinates[max - 1];
                ....

感谢您的帮助

0 个答案:

没有答案