0
0

More than 1 year has passed since last update.

JavaScript メソッド「write」と「name:value」変数定義

Last updated at Posted at 2022-07-25
<body>
<script>
var person=
{
	firstname : "John",
	lastname  : "Doe",
	id        :  5566,
  fullName : function() 
	{
       return this.firstName + " " + this.lastName;
    }
};
// 下記二つ書き方の値一緒=Doe
var personLastName1 = person.lastname;
var personLastName2 = person["lastname"];
document.write(personLastName1 + "<br>");
document.write(personLastName2 + "<br>");

document.write("fullNameメソッド()なし:" + person.fullName + "</br>");
document.write("fullNameメソッド()ある:" + person.fullName());
</script>
</body>

上記の結果:
Doe
Doe
fullNameメソッド()なし:function(){return this.firstName + " " + this.lastName;}
fullNameメソッド()ある:John Doe

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0