ES6 常用函数

forEach 循环数组对象,不会跳出循环

arr.forEach(function (item, index, arr) {
    // item,单个对象
    // index 索引
    // arr完整的集合对象
});

获取对象数组中某一个属性的value集合

arr为对象数组,name是对象的属性名称,返回value数组集合

      var keys = Array.from(arr,({name}) => name);

reduce,待完善,仅供参考

   
      var arr = self.$children.reduce((components, child) => {
        if (child.$options.name === componentName) {
          if(dataSourceKey.indexOf( child.widget.options.remoteDataSource) >=0){
            components.push(child);
          }
          return components;
        }else{
          const foundChilds = this.findChildrensComponent(child, componentName,dataSourceKey);
          return components.concat(foundChilds);
        }
      }, []);
posted @   亘古不变  阅读(4)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示