JavaScript Array reverse 方法

JavaScript About 551 words

引用类型

        const arr = [
            {amount: 39.9, name: "product c"},
            {amount: 19.9, name: "product a"},
            {amount: 29.9, name: "product b"},
        ];
        const reverse = arr.reverse();
        console.log(reverse);

输出

[
    {
        "amount": 29.9,
        "name": "product b"
    },
    {
        "amount": 19.9,
        "name": "product a"
    },
    {
        "amount": 39.9,
        "name": "product c"
    }
]

基础类型

const numbers = [3, 5, 6, 1].reverse();
console.log(numbers)

输出

[
    1,
    6,
    5,
    3
]
Views: 11 · Posted: 2025-12-01

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓
Today In History
Browsing Refresh