Edit in JSFiddle

var $result = $('#result');

// We can use tilde for functions that return -1
var text = $('#test').text(),
    no = text.indexOf('not there'),
    yes = text.indexOf('test');

log('indexOf(not there)', function() { return ~no });
log('!!indexOf(not there)', function() { return !!~no });
log('!!indexOf(is there)', function() { return !!~yes });







function log( test, fn ) {
    $result.append('<tr><td>' + test + ': </td><td>' + fn() + '</td></tr>');
}
<div id="test">test</div>
<table id="result"></table>
#test { display: none; }
table { width: 400px; }
td { width: 50%; }
td:nth-child(2) { color: blue; }