如何获取 [ ["x","y"] ,"z"] 而不是 ["x","y"0x104 5?6710-6ren"> 如何获取 [ ["x","y"] ,"z"] 而不是 ["x","y"0x104 5?6710-这很奇怪,但我找不到任何简单的解决方案。 注意:我使用不变性,所以我绝对不想修改原始数组(不建议使用push) [].concat(["x","y"],"z") -> 如何获取 [["x","y"],-6ren">
gpt4 book ai didi

javascript - [].concat( ["x","y"] ,"z") -> 如何获取 [ ["x","y"] ,"z"] 而不是 ["x","y"0x104 5?6710

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:23:11 24 4
gpt4 key购买 nike

这很奇怪,但我找不到任何简单的解决方案。

注意:我使用不变性,所以我绝对不想修改原始数组(不建议使用push)

[].concat(["x","y"],"z") -> 如何获取 [["x","y"],"z "] 而不是 ["x","y","z"]

最佳答案

您可以使用嵌套数组:

> [].concat([["x", "y"]], "z")

[["x", "y"], "z"]

关于javascript - [].concat( ["x","y"] ,"z") -> 如何获取 [ ["x","y"] ,"z"] 而不是 ["x","y"0x104 5?6710,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31207640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com