How to replace the null value of js json array with'-'

[
{name:a,id:""},
{name:c,id:"d"},
{name:b,id:""},
{name:y,id:"d"},
{name:s,id:6},
{name:p,id:3},
]

how does the data from the background replace all the empty ones with"-"

Oct.30,2021

just write a regular replace replacement, right? Your data is not embedded deeply,


let arr = JSON.parse (data)
arr = arr.map (e = > {.e, id: e.id =''?'-': e.id})


can be replaced when displayed on the page, and there is no need to change the array. If you have to change the array, you can do this:

arr.forEach(v=>{  
    if(v.id == "") {
        v.id = "-";
    }  
});

   

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e52c-2c3fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e52c-2c3fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?