Why do JavaScript functions return undefined
by default instead of null
? Is this a totally arbitrary choice by the specification, or is there a larger ECMAScript-behavior context in which this particular choice can be understood?
function a() {}
a();
// undefined
What is the difference between null
and undefined
? Is there a specification-based reason why is undefined
more appropriate as a default return value, or was it an arbitrary choice?