Home > Q&A > body text
<script>var a={}a.name='hahaha';a.age=20;a.say=function(){"hello"};document.write(a.say())< ;/script>/*Why does the browser output undefined when accessing the object say? Can't the function value be output directly? */
Guanhui2020-05-04 10:44:02
Because there is no return in your say() method
correct answer. //say=function(){"hello"}; say=function(){return "hello"};