js destructuring assignment bug

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment


const getShapeCenterPoint = (points = [], type = "object") => {
// 设置旋转的 origin,为 polygon 的中心,旋转偏移量
let [top, left, right, bottom] = ["", "", "", ""];
// bug ???
// points.forEach((type === "object" ? {x, y} : [x, y], i) => {
// points.forEach(({x, y}, i) => {
// points.forEach(([x, y], i) => {
points.forEach(type === "object" ? {x, y} : [x, y], i => {
if (i === 0) {
top = y;
bottom = y;
left = x;
right = x;
} else {
top = Math.min(top, y);
bottom = Math.max(bottom, y);
left = Math.min(left, x);
right = Math.max(right, x);
}
});
const point = {
cx: (left + right) / 2,
cy: (top + bottom) / 2,
};
return point;
}

最新文章

  1. UVA 12544 - Beehives O(nm) 无向图最小环
  2. jQuery EasyUI教程之datagrid应用(一)
  3. 【MVC 4】3.MVC 基本工具(创建示例项目、使用 Ninject)
  4. 【poj1740】 A New Stone Game
  5. WHERE谓词对索引使用的影响
  6. echarts 问题2
  7. PAT - IO-01. 表格输出(5)
  8. jquery trigger传值
  9. jQuery 源码分析和使用心得 - core.js
  10. jbpm4.3表结构和表字段说明
  11. AJAX 跨域请求的解决办法:使用 JSONP获取JSON数据
  12. JDBC连接数据库(二)——连接池
  13. java 线程中断机制
  14. Linux shell指令运行的原理
  15. 华为CloudIDE免费公测,带你出坑带你飞
  16. js,jQuery实现可关闭悬浮框广告特效,兼容(谷歌,火狐,Ie)
  17. 登陆ArcGIS Server Manager时一直显示”请稍后……”
  18. MySQL-五种日志(查询日志、慢查询日志、更新日志、二进制日志、错误日志)、备份及主从复制配置
  19. 7处ff与ie中读写html、css相关属性的不同之处
  20. Windows10 Oracle ODBC安装配置

热门文章

  1. 数位dp 笔记
  2. SpringMVC听课笔记(十五:SpringMVC 运行流程)
  3. python 基础学习3 列表和元组 、字符串
  4. Spring Boot 微服务应用集成Prometheus + Grafana 实现监控告警
  5. Flutter--Dart基础语法(四)异步
  6. WPF 之 INotifyPropertyChanged 接口的使用 (一)
  7. 源码剖析ThreadPoolExecutor线程池及阻塞队列
  8. 2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage(11/12)
  9. Codeforces Round #652 (Div. 2) A. FashionabLee(几何)
  10. 2019牛客多校 Round3