I'm reading the source code for the Twitter Bootstrap Tabs Plugin and there's a line that appears to be short hand for something, but I don't understand what it is. Here's a snippet from the source (version 3.0.0):
Tab.prototype.activate = function (element, container, callback) {
var $active = container.find('> .active')
var transition = callback
&& $.support.transition
&& $active.hasClass('fade')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
// some code removed for conciseness
callback && callback()
}
The line in question is this: callback && callback()
.
I've never seen a function or variable name just typed out like that and then a function being called after the &&
operator.
I'm guessing this is short hand. What is it and what is it meant to do? And how does it work?