Created
June 27, 2016 08:52
-
-
Save ksakae1216/72ef05acb4484a0e6fdda5b44f7efb68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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