Answers for "how to replace empty string with undefined"

0

how to replace empty string with undefined

var ab = {
firstName : undefined,
lastName : undefined
}

let newJSON = JSON.stringify(ab, function (key, value) {return (value === "") ? undefined : value});

console.log(JSON.parse(newJSON))
Posted by: Guest on August-04-2020

Code answers related to "how to replace empty string with undefined"

Code answers related to "Javascript"

Browse Popular Code Answers by Language