How to remove null bytes from Javascript strings

Given a table, when the user selects a row I save the values of that row in an array.

Code:

var outer_array = []
//loop through checked checkboxes
$("tbody input[type=checkbox]:checked").each(function(index, item) {
    var inner_array = []
    var selector = $(this).closest("tr") //get closest tr
    //loop through trs td not first one
    selector.find("td:not(:first)").each(function() {
        inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim())
        //push in inner array
    })
    outer_array.push(inner_array) //push in outer array
})

For some reason, inner_array contains unwanted characters such as the byte: "b'x00'"

These characters cause me problems on the back-end as python interprets backslash as a special character.

How could I get rid of those unwanted byte characters?

For example, instead of pushing that byte, I would like to push an empty string (pseudo):

if (byte_code){
    innter_array.push('')
} else {
    inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim());
}

enter image description here

Answer

Just replace them before

It is also more DRY

const text = $(this).text().trim().replace(/b'\x00'/g,"")
inner_array.push($.isNumeric(text) ? Number(text) : text)