undefined, null
JavaScript
xxxxxxxxxx
function checkVariable(variable) {
if(variable == null) {
console.log('The variable is undefined or null');
}
else {
console.log('The variable is neither undefined nor null');
}
}
let newVariable;
checkVariable(5);
checkVariable('hello');
checkVariable(null);
checkVariable(newVariable);
The variable is neither undefined nor null The variable is neither undefined nor null The variable is undefined or null The variable is undefined or null
typeof
JavaScript
xxxxxxxxxx
function checkVariable(variable) {
if( typeof variable === 'undefined' || variable === null ) {
console.log('The variable is undefined or null');
}
else {
console.log('The variable is neither undefined nor null');
}
}
let newVariable;
checkVariable(5);
checkVariable('hello');
checkVariable(null);
checkVariable(newVariable);
The variable is neither undefined nor null The variable is neither undefined nor null The variable is undefined or null The variable is undefined or null
Linux - Comment installer anc-api-tools
Linux - Comment installer curvedns
Linux - Comment installer zenmap
Python - Vérifier si un nombre est positif, négatif ou 0
C - Compter le nombre de chiffres dans un entier
C++ - Vérifier si un nombre est premier ou non
C - Trouver le plus grand nombre à l'aide de l'allocation de mémoire dynamique
C++ - Vérifier l'année bissextile
Kotlin - Inverser un nombre
JavaScript - Vérifier si une chaîne commence et se termine par certains caractères
Linux - Comment installer zstd
C++ - Trouver le quotient et le reste
Python - Écriture de fichiers Excel (XLSX)
Linux - Comment installer xbitmaps
Kotlin - Trouver la factorielle d'un nombre
Java - Inverser un nombre
Kotlin - Arrondir un nombre à n décimales
Java - Créer une pyramide et un motif
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month