JSFiddle - React, Tailwind, and code Playground
JavaScript
function Properties(val1, val2, val3, val4){
this.prop1 = val1 || "";
this.prop2 = val2 || "";
this.prop3 = val3 || "";
this.prop4 = val4 || {};
}
Properties.prototype = {
isEmpty: function(obj, keys) {
keys = keys || [];
obj = obj || this;
for (var key in obj) {
if (typeof obj[key] === "object" && obj.hasOwnProperty(key)) {
this.isEmpty(obj[key], keys)
} else {
if (obj[key] == "" || obj[key] == null) {
keys.push(key);
}
}
}
return keys;
}
}
var test = new Properties("Something", "", "", {subProp1: "Something Else", subProp2: "", subProp3: {subSubProp1: "", subSubProp2: "" }});
console.log(test);
var keys = test.isEmpty();
console.log(keys);