Тестовая переменная тип JavaScript

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