Forum Discussion
BenoitB
4 years agoCommunity Hero
The one-in-all is :
/**
* Tester si une variable est vide
* @function
* Param {Object} variable - Variable à évaluer, les objets complexes (plus d'un niveau) ne sont pas évalués correctement
* @returns {boolean} Renvoie <b>true</b> si la variable est null ou undefined ou "" ou tableau/objet simple vide
*/
function isEmpty(Variable) {
if ((typeof Variable == 'object') && (Variable.constructor === Object))
return Object.keys(Variable).length === 0
else
return ((typeof Variable == 'undefined') || (Variable == null) || ((typeof Variable == 'string') && ((Variable == '') || (Variable == 'undefined'))) || ((typeof Variable == 'object') && (Variable.length == 0)));
}