how to replace empty string with undefined

Solutions on MaxInterview for how to replace empty string with undefined by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "how to replace empty string with undefined"
Mia
14 Mar 2019
1var ab = {
2firstName : undefined,
3lastName : undefined
4}
5
6let newJSON = JSON.stringify(ab, function (key, value) {return (value === "") ? undefined : value});
7
8console.log(JSON.parse(newJSON))