var a = null, b = null;
var a, b;
This question is tagged with
~ Asked on 2013-05-10 03:37:25
I declare them as undefined when I don't assign a value because they are undefined after all.
~ Answered on 2013-05-10 03:39:57
It depends on the context.
"undefined" means this value does not exist.
typeof returns "undefined"
"null" means this value exists with an empty value. When you use
typeof to test for "null", you will see that it's an object. Other case when you serialize "null" value to backend server like asp.net mvc, the server will receive "null", but when you serialize "undefined", the server is unlikely to receive a value.
~ Answered on 2013-05-10 03:52:50