I accidentally came across $(undefined) in a statement below, where params is an object:
var $this = $(params._this) || $(this);
This did not work, as $(params._this) is a jQuery object and is always evaluated to true.
Funny enough, I was not sure how to check for it. It is not an empty object (i.e. $.isEmptyObject($(undefined)) == false), nor is it a function or a “plain object” (i.e. $.isPlainObject()).
I ended up modifying the statement to the following:
var $this = (params._this == undefined) ? $(params._this) : $(this);
My question is, is there any way to “evaluate” (not sure what word to use) $(undefined)? Is there any use for this?
1 Answer