javascript - Why does this JS return false for a non-integer? -


here code function - great jquery cycle plugin

function calculatetimeout(currelement, nextelement, opts, isforward) {  var index = opts.currslide;  return index % 2 ? 2000 : false;  }  

i , working fine the last line curious about.

  1. "return" kills function , returns ever output has
  2. index variable set in above line (is integer)
  3. "% 2" divides index var 2
  4. then "? 2000 : false" short hand if else , if statement true / false return either 2000 or false.

so 3 return true , 3.5 return false example.

so question why in context integer return true non-integer return false? might have thought number return true , 0 return false?

guessing due type casting set?

thanks


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -