diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index bc4c0a57..0458e532 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -52,6 +52,34 @@ function emptyElem(container){ return true; } +/** + * Delete all the content of an object + * + * @param {Object} object The object to clear + * @return {Boolean} True for a success + */ +function clearObject(object){ + + //Variable (for loop) is specific to this local scop + var i = 0; + + //Process each node of the object + for(i in object){ + + //Check if the node is an object + if(object[i].toString() === "[object Object]"){ + clearObject(object[i]); //Delete object content + console.log("Hello world"); + } + + //Delete node + delete object[i]; + } + + //Success + return true; +} + /** * Check a given email address *