Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.