<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
</style>
</head>
<body>
<div id="wrap"></div>
<script>
// 可以遍历的必须带有iterable属性
let a = {
name:"knight",
age:18,
gender:"nan"
};
// 所有的键
for (let i of Object.keys(a)){
console.log(i);
}
// 所有的值
for (let i of Object.values(a)){
console.log(i);
}
// 所有的键值对 数组
for (let i of Object.entries(a)){
console.log(i);
}
// 解构赋值
for (let [key,value] of Object.entries(a)){
console.log(key);
console.log(value);
}
</script>
</body>
</html>
Python3Turtle