<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA_Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<script>
// Object.keys0)用于获取对象自身所有的属性名
// object.keys(obj)
// 效果类似for...in
// 返回一个由属性名组成的数组
var obj = {
id:1,
pname:'小米',
price:1999,
num:2000
};
var arr = Object.keys(obj);
console.log(arr);
arr.forEach(function (qurrentValue) {
console.log(qurrentValue);
})
</script>
</head>
<body>
</body>
</html>
javascript 对象方法Object.key()
猜你喜欢
转载自blog.csdn.net/weixin_45949073/article/details/107444271
今日推荐
周排行