引用對象加不加括號區別
阿新 • • 發佈:2017-07-03
ast john utf tel 對象 函數 doctype per fun
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 id="demo1"></h1>
<h1 id="demo2"></h1>
<script>
var person = {
firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function()
{
return this.firstName + " " + this.lastName;
}
};
document.getElementById("demo1").innerHTML = "不加括號輸出函數表達式:" + person.fullName;
document.getElementById("demo2").innerHTML = "加括號輸出函數執行結果:" + person.fullName();
</script>
</body>
</html>
引用對象加不加括號區別