<!DOCTYPE html>
<html lang="utf-8">
<head>
<meta http-equiv="content-type" type="text/html;charset=utf-8">
<title>Object.keys()应用</title>
<script type="text/javascript">
var person={
firstName:"David",
lastName:"Walsh",
others:"Smith"
};
Object.keys(person).forEach(function(trait){
console.log('person',trait,':',person[trait]);
});
</script>
</head>
<body>
<body>
</html>
输出如下: person firstName : David person lastName : Walsh person others : Smith
|