What is the difference between undefined and null in JavaScript?
The key difference is that undefined means a variable has been declared but not assigned a value, whereas null is an explicit assignment value representing 'no value' or 'no object'. undefined is also the default return value of functions that don't explicitly return anything, and the value of formal parameters that aren't provided when a function is invoked. null is an intentional absence of any object value that must be explicitly assigned. Additionally, typeof undefined returns 'undefined', while typeof null incorrectly returns 'object' due to a historical bug in JavaScript.