mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Created a clean object function
This commit is contained in:
parent
fa5cbdf9a6
commit
a334b2b30e
@ -52,6 +52,34 @@ function emptyElem(container){
|
|||||||
return true;
|
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
|
* Check a given email address
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user