Skip to content

Instantly share code, notes, and snippets.

@sevperez
Last active July 8, 2018 21:51
Show Gist options
  • Save sevperez/8af626364c8d15effb5762e3cd339a20 to your computer and use it in GitHub Desktop.
Save sevperez/8af626364c8d15effb5762e3cd339a20 to your computer and use it in GitHub Desktop.
var products = {
"widget": 400,
"gear": 80,
"crank": 375,
"lever": 870,
};
var otherProducts = Object.create(products);
otherProducts["wheel"] = 210;
var otherProductKeys = Object.keys(otherProducts);
console.log("otherProductKeys: ", otherProductKeys);
// logs otherProductKeys: [ "wheel" ]
for (var i = 0; i < otherProductKeys.length; i += 1) {
var key = otherProductKeys[i];
console.log(key + " : " + otherProducts[key]);
}
// logs "wheel: 210"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment