I would make use of operator short circuiting:
return this.is('input:text') && $.trim(this.val()).length === 0;
If this.is('input:text')
is false
, the second part won't need to be evaluated, as false && any boolean
will be false
regardless of the other boolean's value. It acts like your if
statement.