I am trying to figure out what the below syntax do. It's code from Bootstraps popover.
//title is a string
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
                           ^                                                 ^
                       What does this symbol mean?                    Whats happening here?
                Let's break it up:
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
It can be broken down into this:
var found = $tip.find('.popover-title');
found[$.type(title) == 'object' ? 'append' : 'html'](title);
And more:
var found = $tip.find('.popover-title');
if ($.type(title) == 'object') {
  found['append'](title);
} else {
  found['html'](title);
}
A little more:
var found = $tip.find('.popover-title');
if ($.type(title) == 'object') {
  found.append(title);
} else {
  found.html(title);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With