Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Replace empty strings in object with null values

const obj = {
  value1: 'bacon',
  value2: '',
  value3: 'lard',
  value4: '',
  value5: 'cheese',
};

Object.keys(obj).reduce((acc, key) => {acc[key] = obj[key] === '' ? null : 
obj[key]; return acc; }, {})
Comment

PREVIOUS NEXT
Code Example
Javascript :: add fraction in angular 
Javascript :: opposite number js 
Javascript :: deploy react to azure : web.config 
Javascript :: canvas set line opacity 
Javascript :: separador de miles javascript 
Javascript :: react native sectionlist filter 
Javascript :: react i18n with parameeter 
Javascript :: Apollo graphql fragment 
Javascript :: JavaScript - Closures 
Javascript :: react show view based on role permission 
Javascript :: selectboxit 
Javascript :: javascript array erstellen 
Javascript :: json schema beispiel 
Javascript :: react hook form submit outside form 
Javascript :: socket io express 
Javascript :: document.queryselector scrolltop 
Javascript :: react linking to documents 
Javascript :: timestamp discord.js 
Javascript :: like php date("Y-m-d",$value) in javascript 
Javascript :: ionic vue use .env 
Javascript :: javascript 
Javascript :: localstorage.setitem 
Javascript :: html select multiple selected values 
Javascript :: how to define cardTitle background image in mdl in reactjs 
Javascript :: jstree expend all node 
Javascript :: dotenv in node js 
Javascript :: display month friday 13th javascript year 
Javascript :: change element text innerhtml keeping the elements or tags inside 
Javascript :: rating calculator formula javascript 
Javascript :: to do list app react code 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =