扫码关注官方订阅号
我印象中记得看过某断代码,他的返回大概是
function a{ 。。。。 return{ ... ... ... ... } }
具体怎么写忘记了,返回中有 花括号 是什么意思呢,能不能写个例子
欢迎选择我的课程,让我们一起见证您的进步~~
返回一个对象
function test(){ return { name:"test", age:23 } } var obj = test(); alert(obj.name); //test
有花括号代码里面是一个对象,如
function a (){ return { b: "hello,world" } }
然后
> a().b "hello,world"
这里的b也可以是一个方法
function a (){ return { b: function(){ console.log("hello,world") }}}
{} 定义对象字面量
{}
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
返回一个对象
有花括号代码里面是一个对象,如
然后
这里的b也可以是一个方法
{}定义对象字面量