In jquery jQuery.fx.off will return bool
. But when I am executing the following line I am getting undefined
.
alert(jQuery.fx.off);
Please tell me why is it so.
In jquery jQuery.fx.off will return bool
. But when I am executing the following line I am getting undefined
.
alert(jQuery.fx.off);
Please tell me why is it so.
In recent versions, at least, jQuery doesn't assign an initial value to jQuery.fx.off
, leaving it undefined
by default.
jQuery just tests whether it has a value and if that value is truthy:
jQuery.speed = function( speed, easing, fn ) {
// ...
opt.duration = jQuery.fx.off ? 0 : // ...
// ^^^^^^^^^^^^^
To get a boolean based on its truthiness, you can use the Boolean()
function (without new
) or double !!
:
alert(jQuery.fx.off); // undefined
var fxOff = Boolean(jQuery.fx.off);
alert(fxOff); // false