Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
Created June 27, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksakae1216/72ef05acb4484a0e6fdda5b44f7efb68 to your computer and use it in GitHub Desktop.
Save ksakae1216/72ef05acb4484a0e6fdda5b44f7efb68 to your computer and use it in GitHub Desktop.
function showProps(obj, objName) {
var result = "";
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
result += objName + "." + i + " = " + obj[i] + "\n";
}
}
return result;
}
var myCar = new Object();
myCar["make"] = "Ford";
myCar["model"] = "Mustang";
myCar["year"] = 1969;
console.log(showProps(myCar, "myCar"));
//出力結果
myCar.make = Ford
myCar.model = Mustang
myCar.year = 1969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment