将对象转化为数组
方法一:
1234567let obj={a:1,b:2}let arr = []let x=Object.entries(obj)//[["a", 1],["b", 2]]arr=x.map(item=>{return item[1]})console.log(arr)//[1,2]方法二:
1234567let obj={a:1,b:2}let arr = []for (let i in obj) {arr.push(obj[i]); //属性//arr.push(obj[i]); //值}console.log(arr);//[1,2]方法三:
123let obj={a:1,b:2}let arr = Object.values(obj)console.log(arr);//[1,2]