引用对象的实例代码分享
程序员文章站
2022-05-19 23:37:59
...
<!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>
以上就是引用对象的实例代码分享的详细内容,更多请关注其它相关文章!