Skip to content

Instantly share code, notes, and snippets.

@corespider
Created August 13, 2021 20:05
What is the difference between null and undefined in JavaScript?
null === undefined // false
null !== undefined // true
// Example
function PrintLog(str = 'Test') {
console.log(str);
}
PrintLog(); // Prints 'Test'
PrintLog("Hello World"); // Prints 'Hello World'
// But the surprise is here,
PrintLog(undefined); // Prints 'Test'
PrintLog(null); // Prints 'null'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment