-2

Why does JavaScript has both undefined and null

What purpose do they serve

Why can't JavaScript use null for all unassigned values as Java?

Vinay
  • 89
  • 6
  • Please search the site before asking any question, that one was easy to find. – blex Aug 22 '14 at 20:07
  • Avoid to ask "why" questions. Most likely only people directly working on the language can answer them. I'm pretty sure though that Brendan Eich was asked this many times. – Felix Kling Aug 22 '14 at 20:11
  • 1
    ok @Vinay, [**that comment**](http://stackoverflow.com/questions/5076944/what-is-the-difference-between-null-and-undefined-in-javascript#comment-9782995) (25 upvotes) might help you. Hope your interview went well. – blex Aug 22 '14 at 20:15

1 Answers1

1

Null means its set to a null set, like in Set Theory. But Null is still defined.

The logic for undefined naturally follows.

All these concepts are from Mathematics. In fact programming is essentially just Linear Algebra.

codehitman
  • 1,120
  • 9
  • 31