HTML5

http://html5demos.com/

https://www.webcodegeeks.com/html5/html5-page-structure-example/

 

HTML5 + CSS3

https://tutorialzine.com/2010/02/html5-css3-website-template

 

Show value of object

function showObject(obj) {
  var result = "";
  for (var p in obj) {
    if( obj.hasOwnProperty(p) ) {
      result += p + " , " + obj[p] + "\n";
    } 
  }              
  return result;
}

function showObjectjQuery(obj) {
  var result = "";
  $.each(obj, function(k, v) {
    result += k + " , " + v + "\n";
  });
  return result;
}

var test = { 
    'type' : 'news', 
    'name' : 'article1' 
};


showObject
(test); // type , news name , article1
showObjectjQuery(test); // type , news name , article1


https://www.sitepoint.com/back-to-basics-javascript-object-syntax/
https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_slice1
https://coderwall.com/p/_kakfa/javascript-iterate-through-object-keys-and-values

LOOP

var cties = {
"USA":[{"country":"Albuquerque (ABQ)"}, {"country":"Allentown (ABE)"}],
"Canada":{"country":"Calgary (YYC)"},
"Hawaii":{"country":"Honolulu International Apt (HNL)"}
};

for(var key in cties){
console.log(key + " : " + cties[key].country);
}

JavaScript LOOP

var homes = [
{
"h_id": "3",
"city": "Dallas",
"state": "TX",
"zip": "75201",
"price": "162500"
},

{
"h_id": "4",
"city": "Bevery Hills",
"state": "CA",
"zip": "90210",
"price": "319250"
},

{
"h_id": "5",
"city": "New York",
"state": "NY",
"zip": "00010",
"price": "962500"
}
];

 

// ES5: Under ECMAScript 5, you can combine Object.keys() and Array.prototype.forEach():

Object.keys(homes).forEach(function(key) {
    console.log(key, homes[key]);
});

 

// ES6: Arrow function

Object.keys(homes).forEach(key => {
    console.log(key); // the name of the current key.
    console.log(homes[key]); // the value of the current key.
});  

 

// Inline

Object.keys(homes).forEach(key => console.log(key, homes[key]));

 

// ES7: Using Object.entries

Object.entries(homes).forEach(([key, val]) => {
    console.log(key); // the name of the current key.
    console.log(val); // the value of the current key.
});

 

// ES6: Recursive function

const loopNestedObj = (obj) => {
Object.keys(obj).forEach(key => {
if (obj[key] && typeof obj[key] === 'object') loopNestedObj(obj[key]); // recurse.
else console.log(key, obj[key]); // or do something with key and val.
});
};

loopNestedObj(homes);

 

// ES7: Using Object.entries instead of Object.keys

const loopNestedObj = (obj) => {
Object.entries(obj).forEach(([key, val]) => {
if (val && typeof val === 'object') loopNestedObj(val); // recurse.
else console.log(key, val); // or do something with key and val.
});
};

loopNestedObj(homes);

 

How to Loop through plain JavaScript object with objects as members?

for (var key in homes) {
// skip loop if the property is from prototype
if (!homes.hasOwnProperty(key)) continue;

var obj = homes[key];
for (var prop in obj) {
// skip loop if the property is from prototype
if(!obj.hasOwnProperty(prop)) continue;

// your code
console.log(prop + " = " + obj[prop]);
}

Looping through all of the items in the window object?

do {
Object.getOwnPropertyNames(homes).forEach(function(name) {
console.log(name);
});
console.log("=============================");
} while(homes = Object.getPrototypeOf(homes));