if(window !== 'undefined') code example Example: if window undefined if (typeof window !== 'undefined')