Problem creating objects
小龙
小龙 2020-04-28 11:58:21
0
2
1026

<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? */

小龙
小龙

reply all(1)
凉官灰

Because there is no return in your say() method

  • reply correct answer. //say=function(){"hello"}; say=function(){return "hello"};
    DY。 author 2020-05-08 01:52:29
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template