一.Object.keys()的用法
返回值:
1.传入对象,返回属性名
2.传入字符串,返回索引
3.构造函数 返回空数组或者属性名
①对象,返回对象的key值组成的数组(字符串类型的)
代码演示:
let obj={
name:"zhangsan",
age:18,
gender:"male"
}
console.log(Object.keys(obj));//[ 'name', 'age', 'gender' ]
输出结果:

②字符串,返回字符串索引组成的数组(字符串)
let str = "Hello";
console.log(Object.keys(str));//[ '0', '1', '2', '3', '4' ]
输出结果:

二.Object.values()的用法
返回值:
1.传入对象,返回value值
2.传入字符串,返回单个字符
3.传入数组,返回该数组
4.构造函数 返回空数组或者属性名
①对象,返回对象的value值组成的数组(字符串)
代码演示:
let obj={
name:"张三",
age:18,
gedner:"男"
}
for(let item in obj){
console.log(item);// name age gender
}
console.log(Object.values(obj));//[ '张三', 18, 'male' ]
输出结果:

②数组,返回该数组
let arr = [20,10,30];
console.log(Object.values(arr));//[ 20, 10, 30 ]
输出结果: 
③字符串,返回单个字符组成的数组(字符串类型)
let str = "hello";
console.log(Object.values(str));//[ 'h', 'e', 'l', 'l', 'o' ]
输出结果: 