Category: JavaScript

The Ternary Operator: Shorthand for if/else

I ran into this when going through a slideshow tutorial from Six Revisions, so I thought I would find out what it was and how it worked. Here’s the snippet from that slideshow tutorial that contains the ternary operator: currentPosition = ($(this).attr(‘id’)==’rightControl’) ? currentPosition+1 : currentPosition-1;//Determine new position What It Is A ternary operator is [...]