javascript remove empty object items
var test = {
test1: null,
test2: 'somestring',
test3: 3,
}
function clean(obj) {
for (var propName in obj) {
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
return obj
}
console.log(test);
console.log(clean(test));
Also in JavaScript:
- abstraction in javascript
- how to get create an array in javascript
- js unique using set
- sorting number with coma datatable
- how to pass props in react test cases
- crucer in js
- how to check if object exists in javascript
- program to parenthesize an expression
- javascript get div x y position
- JS truthy value of void
- jsconfig for default vue
- how to code print in javascript
- angular bootstrap
- d3js circle out of scrren
- paper material ui improt
- jquery loop through each child element
- how to write a program that determines the minutes since midnight, Jan 1, 1970 in javascript
- user input through js
- new Map() collection in react state
- react materialize cdn
- how to eat beans in javascirpt
- how to set up a success message show up if form is submitted in react hooks
- append to top javascript
- https with express