![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
qq_44209563
这个作者很懒,什么都没留下…
展开
-
js 遍历对象及遍历数组
1. 遍历对象需求:将数据 {"cluster":"os","softname":"k8s"}变成以下形式:[ { "name": "cluster", "value": "os" }, { "name": "softname", "value": "k8s" }]代码:let res = {"cluster":"os","softname":"k8s"}let list = []for (v原创 2022-03-10 21:27:40 · 1247 阅读 · 0 评论 -
js 修改对象中的key值
对象中的信息如下,需要修改的key是id(从id 改成departmentId)将原来的key删除,重新添加一个新的key,代码如下: //保存原来key对应的值 let departmentId= department.id; //删除key delete department.id //增加key department.departm原创 2022-01-11 10:01:38 · 4954 阅读 · 0 评论 -
js 比较两个json数组,去除重复元素
有如下两个json数组: a和b;let a =[{ "id": 1, "name": "姓名", "code": "name"}, { "id": 2, "name": "年龄", "code": "age"}, { "id": 3, "name": "地址", "code": "addr"}, { "id": 4, "name": "搜索", "code": "as"}]let b= [{ "id": 1, "name": "姓名", "code": "nam原创 2021-12-26 15:08:15 · 2185 阅读 · 0 评论