<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript for..in loop to iterate object</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script type="text/javascript">
var myObj = {
"commercial": ".com",
"network": ".net",
"organization": ".org",
"government": ".gov"
};
for(key in myObj){
document.writeln(key + " domain : " + myObj[key]);
}
</script>
</pre>
</body>
</html>