Tester le type de variable JavaScript

if(typeof bar === 'string') {
   //whatever
}
CollectiveMind