1var test = {
2 test1: null,
3 test2: 'somestring',
4 test3: 3,
5}
6
7function clean(obj) {
8 for (var propName in obj) {
9 if (obj[propName] === null || obj[propName] === undefined) {
10 delete obj[propName];
11 }
12 }
13 return obj
14}
15
16console.log(test);
17console.log(clean(test));