{"ScriptPreparationCode":null,"TestCases":[{"Name":"Lodash","Code":"function removeNullUndefined(obj) {\r\n if (_.isArray(obj)) {\r\n return obj.map(element =\u003E (_.isObject(element) ? removeNullUndefined(element) : element)).filter(el =\u003E el !== null \u0026\u0026 el !== undefined);\r\n } else if (_.isObject(obj)) {\r\n return _(obj)\r\n .omitBy(_.isNil)\r\n .mapValues(removeNullUndefined)\r\n .value();\r\n }\r\n return obj;\r\n}\r\n\r\nconst obj = {\r\n a: 1,\r\n b: null,\r\n c: {\r\n d: 2,\r\n e: undefined,\r\n f: {\r\n g: null,\r\n h: 3\r\n }\r\n },\r\n i: [4, null, { j: undefined, k: 5 }]\r\n};\r\n\r\nconst cleanedObj = removeNullUndefined(obj);\r\nconsole.log(cleanedObj);","IsDeferred":false},{"Name":"JS Native","Code":"function removeNullUndefined(obj) {\r\n if (typeof obj !== \u0027object\u0027 || obj === null) {\r\n return obj;\r\n }\r\n\r\n if (Array.isArray(obj)) {\r\n return obj.map(removeNullUndefined);\r\n }\r\n\r\n return Object.keys(obj).reduce((acc, key) =\u003E {\r\n const value = obj[key];\r\n\r\n if (value !== null \u0026\u0026 value !== undefined) {\r\n if (typeof value === \u0027object\u0027) {\r\n acc[key] = removeNullUndefined(value);\r\n } else {\r\n acc[key] = value;\r\n }\r\n }\r\n\r\n return acc;\r\n }, {});\r\n}\r\n\r\nconst obj = {\r\n a: 1,\r\n b: null,\r\n c: {\r\n d: 2,\r\n e: undefined,\r\n f: {\r\n g: null,\r\n h: 3\r\n }\r\n },\r\n i: [4, null, { j: undefined, k: 5 }]\r\n};\r\n\r\nconst cleanedObj = removeNullUndefined(obj);\r\nconsole.log(cleanedObj);","IsDeferred":false}]}