年在学习JavaScript,Java脚本计算时代正在试图提醒用户对象的内容,前三个是显示器,但与函数的函数年龄部位没有,请帮助生完孩子
<!DOCTYPE html>
<html lang="en">
\t <head>
\t \t <script>
\t \t \t var person = {fname: "Asha",lname: "Juma",dob: 2005,age:function(){(new Date().getFullYear() - this.dob);}};
\t \t \t function print() {
\t \t \t \t alert(JSON.stringify(person));
\t \t \t }
\t \t </script>
\t </head>
\t <body>
\t \t <p>Lets hit this button to alert the user of the person object contents</p>
\t \t <button onclick=print()>Click Me!</button>
\t \t
\t </body>
</html>
在你的输出,你希望看到的'age'功能的代码,或给它的调用的结果? – simbabque
结果像年龄:12 – Developer