Edit in JSFiddle

var $foo = $('li');
var $baz = $('#baz1');

console.log('Index: ' + $foo.index($baz)); // 2

var $tests = $(".test");
var $bar = $("#bar1");

// implicitly calls .first() on the argument
console.log('Index: ' + $tests.index($bar)); // 1

console.log('Index: ' + $tests.index($bar.first())); // 1