.concat()连接后为什么把数组变成了string类型?

小程序 文章 2022-04-13 16:40 352 0 全屏看文

AI助手支持GPT4.0

.concat()连接后为什么把数组变成了string类型?Why does .concat() turn the array into a string type after concatenation?

.concat()连接后为什么把数组变成了string类型?

我定义了两个数组一个是comment和commentList,在运用.concat()给commentList拼接的时候为什么是变成了string类型?而同样是拼接为什么comment又是数组类型呢?我打算做一个评论数组(comment)在里面嵌套一个评论详细信息数组(commentList),结果不信

I have defined two arrays, one is comment and the other is comment list Why does concat () become a string when splicing the commentlist? And the same is splicing. Why is comment an array type? I'm going to make a comment array and nest a comment list in it. I don't believe it

回答:

再见,电脑崽:
[userInfo.nickname].concat([userInfo.avatarUrl])
飞:

希望各位大佬可以帮忙解解惑

超:

nickName和avatarUrl都是字符串吧 那拼接出来就是字符串

-EOF-

AI助手支持GPT4.0