<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" > /** * 就是使用for....in 方法遍历对象中的属性名+属性值 */ var obj={ name:"小明", age:"18", sex:"男" } for(var n in obj){ console.log("属性名"+n) console.log("属性值"+obj[n]) } </script> </head> <body> </body> </html>