0

I am reading about filtering values in jQuery, and I passed on this example:

myvalues = $("div.myvalues");
myvalues.filter(function(index){
    return !!$(this).val().length;
});

I am wondering what does the !!$(this).val().length; mean? I know that ! is flipping the operator to false, and !! is flipping it again to true, but what's the idea?

Robert Karl
  • 7,598
  • 6
  • 38
  • 61
Brittany Rutherford
  • 555
  • 1
  • 5
  • 15

1 Answers1

0

this return !!$(this).val().length; will filter out or give every element that doest have value attribute set. of course which means value length will be zero a false when checked with !!

A.B
  • 20,110
  • 3
  • 37
  • 71