js destructuring assignment bug
2024-09-02 19:37:31
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;
}
最新文章
- UVA 12544 - Beehives O(nm) 无向图最小环
- jQuery EasyUI教程之datagrid应用(一)
- 【MVC 4】3.MVC 基本工具(创建示例项目、使用 Ninject)
- 【poj1740】 A New Stone Game
- WHERE谓词对索引使用的影响
- echarts 问题2
- PAT - IO-01. 表格输出(5)
- jquery trigger传值
- jQuery 源码分析和使用心得 - core.js
- jbpm4.3表结构和表字段说明
- AJAX 跨域请求的解决办法:使用 JSONP获取JSON数据
- JDBC连接数据库(二)——连接池
- java 线程中断机制
- Linux shell指令运行的原理
- 华为CloudIDE免费公测,带你出坑带你飞
- js,jQuery实现可关闭悬浮框广告特效,兼容(谷歌,火狐,Ie)
- 登陆ArcGIS Server Manager时一直显示”请稍后……”
- MySQL-五种日志(查询日志、慢查询日志、更新日志、二进制日志、错误日志)、备份及主从复制配置
- 7处ff与ie中读写html、css相关属性的不同之处
- Windows10 Oracle ODBC安装配置
热门文章
- 数位dp 笔记
- SpringMVC听课笔记(十五:SpringMVC 运行流程)
- python 基础学习3 列表和元组 、字符串
- Spring Boot 微服务应用集成Prometheus + Grafana 实现监控告警
- Flutter--Dart基础语法(四)异步
- WPF 之 INotifyPropertyChanged 接口的使用 (一)
- 源码剖析ThreadPoolExecutor线程池及阻塞队列
- 2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage(11/12)
- Codeforces Round #652 (Div. 2) A. FashionabLee(几何)
- 2019牛客多校 Round3