function test1() {
return new Array('11','22')
}
let num1 = test1()
console.log(num1[0], num1[1]) // 11, 22
function test2() {
return [2,3]
}
let num2 = test2()
console.log(num2[0], num2[1]) // 2, 3
function test3() {
return {name:'cookie', age: 18}
}
let num3 = test3()
console.log(num3.name, num3.age) // cookie, 18
在JS函数中返回多个值的方法
最新推荐文章于 2024-03-04 20:27:42 发布