The microquasar GX 339−4, known to exhibit powerful compact jets that dominate its radio to near-infrared emission, entered an outburst in 2010 for the fifth time in about 15 yr. An extensive radio to X-ray multiwavelength campaign was immediately triggered, and we report here on European Southern Observatory/FORS2+ISAAC optical and near-infrared spectroscopic observations, supported by Australia Telescope Compact Array radio and Rossi X-ray Timing Experiment/Swift X-ray quasi-simultaneous data. GX 339−4 was observed at three different epochs, once in the soft state and twice in the hard state. In the soft state, the optical and near-infrared continuum is largely consistent with the Raleigh–Jeans tail of a thermal process. As an explanation, we favour irradiation of the outer accretion disc by its inner regions, enhanced by disc warping. An excess is also present at low frequencies, likely due to an M subgiant companion star. During the first hard state, the optical/near-infrared continuum is well described by the optically thin synchrotron emission of the compact jet combined with disc irradiation and perhaps another component peaking in the ultraviolet. The spectral break where the jet transits from the optically thick to thin regimes, located below 1.20 × 1014 Hz, is not detected and the extension of the optically thin synchrotron is consistent with the 3–50 keV spectrum. In contrast, the emission during the second hard state is more difficult to understand and points towards a more complex jet continuum. In both cases, the near-infrared continuum is found to be variable at time-scales at least as short as 20 s, although these variabilities are smoothed out beyond a few hundred seconds. This implies rapid variations – in flux and frequency – of the location of the spectral break, i.e. dramatic short time-scale changes of the physical conditions at the base of the jet, such as the magnetic field and/or the base radius.