I often see JavaScript code where a function can take an "options" object and use it like:
var name = typeof options.name !== 'undefined' ? options.name : "Bob";
It seems to be equivalent to the following:
var name = options.name || "Bob";
Now I understand that in some situations it may really be interesting for you that options.name is undefined vs null , and this makes sense to me, but I often see this in situations where this difference is not required.
I believe that I heard that people write such code due to some error in IE. Can someone clarify please?
javascript internet-explorer undefined
Bain markev
source share