📜  javascript 解析 php 代码 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:27.175000             🧑  作者: Mango

代码示例2
let cars = [
    {
        "id": 1,
        "code": "C1",
        "color": "purple",
        "type": "minivan",
        "registration": new Date('2017-01-03'),
        "capacity": 7
    },
    {
        "id": 2,
        "code": "C2",
        "color": "red",
        "type": "station wagon",
        "registration": new Date('2018-03-03'),
        "capacity": 5
    },
    {
        "id": 3,
        "code": "C2",
        "color": "black",
        "type": "station",
        "registration": new Date('2018-03-03'),
        "capacity": 9
    }
]
const s = new Set()
cars.forEach((element) => {
    console.log(element.id)
    console.log(s.has(element.code) ? 0 : element.code)
    s.add(element.code)
    console.log(element.color)
    console.log(element.type)
    console.log(element.capacity)
});