Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #replace #empty #string #undefined
ADD COMMENT
Topic
Name
5+8 =