一、对象展开运算,赋值给新对象,并添加新属性
let passParams = {
...queryParams.value,
column:'report_time',
assayState: '2'
}
二、JS解构
2.1 数组解构
let [a, b, c] = [1, 2, 3];
等同于:
let a = 1;
let b = 2;
let c = 3;
2.2 对象解构
let { foo, bar } = { foo: 'aaa', bar: 'bbb' };
foo // "aaa"
bar // "bbb"
2.3 对象解构改字段名
let obj = { first: 'hello', last: 'world' };
let { first: f, last: l } = obj;
f // 'hello'
l // 'world'
2.4 对象解构获取函数
// 例一
let { log, sin, cos } = Math;
// 例二
const { log } = console;
log('hello') // hello
三、JS深拷贝
let rowValue = JSON.parse(JSON.stringify(row))
四、forEach方法
var user = [
{
id: 1,
name: "李四"
},
{
id: 2,
name: "张三"
}
]
var userName = [];
user.forEach((item)=>{
userName.push(item.name);
})
console.log(userName); // ["李四", "张三"]
网友评论