As I said an expression would be valid, this is ok also:
You could ask me:
But if this returns undefined, why not use undefined instead?
Nowadays you can, not a problem.
window.undefined = true
Great, now undefined is true and you are in a debug hell.
Modern browsers doesn't have this problem, since this assignment is not allowed anymore. ES5 solved this mess.
But, just in case you have to support old browsers in your job, these are the list of browsers that allow this re-assign of undefined (source):
- Internet Explorer 8 and below;
- Firefox 3.6 and below;
- Android 4 and below;
- Safari 4 and below;
- Chrome 16 and below;
- Opera 12.5 and below;
- Konkeror 4.3 and below.
Some people say they use it instead of undefined because you use less chars. I really don't think this 2 characters, even it is being used a lot of times, will be a great gain but
Is it used by someone?
Yeap, I believe that is just for compatibility reasons but same example of real world are:
- Underscore : function for checking if a parameter is undefined (isUndefined());
- Backbone : function for clearing model attributes (clear());
- ThreeJS : some minifiers change undefined for void 0, as you can see here
Should I change my code and stop using undefined?
The most correctly answer would be: Depends. It depends on your browser support, and maybe on your concern about file size (really?).
But my anwser is: Ok, it depends, but probably you don't need to change. Nowadays it is more about your taste and maybe your project structure. But are not wrong using undefined, at all.