Skip to main content
NaN is not equal to zero, therefore this is correct, I reverted back one version
Source Link

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 (and NaN) means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 (and NaN) means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

added NaN
Source Link
Tim Büthe
  • 63.9k
  • 17
  • 96
  • 130

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 (and NaN) means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 (and NaN) means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

In JavaScript, everything is truthy'truthy' or falsy'falsy', and for numbers, 0 0 means falsefalse, everything else truetrue. So you could write:

if ($(selector).length)

and youYou don't need that > 0>0 part.

In JavaScript, everything is truthy or falsy and for numbers, 0 means false, everything else true. So you could write:

if ($(selector).length)

and you don't need that > 0 part.

In JavaScript, everything is 'truthy' or 'falsy', and for numbers 0 means false, everything else true. So you could write:

if ($(selector).length)

You don't need that >0 part.

Rollback to Revision 3
Source Link
Shikkediel
  • 5.2k
  • 16
  • 50
  • 80
Loading
added 3 characters in body
Source Link
Arslan Ali
  • 17.9k
  • 9
  • 64
  • 84
Loading
edited body
Source Link
Tim Büthe
  • 63.9k
  • 17
  • 96
  • 130
Loading
Corrected typo
Source Link
Cory House
  • 15.1k
  • 13
  • 75
  • 89
Loading
Source Link
Tim Büthe
  • 63.9k
  • 17
  • 96
  • 130
Loading