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