Windowing is more in the realms of signal processing theory than programming, however it is very important when understanding the output of an FFT, so probably worth explaining in a little more detail.
Essentially, when you truncate a signal (for example process it in blocks), you are altering the frequency domain in a rather surprising way. You end up convolving (i.e. smearing) all frequency terms with a "window" function. If you do nothing other than truncate, then that function is sin()/sin(). What happens is that this spreads the frequency content of the original signal over the entire spectrum, and if there is a dominant component, then everything else gets buried by this. The shorter the blocks, the worse the effect is as the window gets fatter in the frequency domain.
Windowing with shaped window, such as Hamming, Hanning or Blackman, alters the frequency domain response, making the smearing more localised to the original signal. The resulting frequency domain is much clearer as a result.
To analyse a block of data, x, then what you should do is
transform=fft(x.*hanning(length(x)));
The result will be complex, which you can display with plot(20*log10(abs(transform)))
For a mathematical analysis see https://cnx.org/contents/4jyGq_c3@6/Spectrum-Analysis-Using-the-Di
If you want a practical hands-on experience of what windowing does, try https://cnx.org/contents/CJ3fYEow@2/Spectrum-Analyzer-MATLAB-Exerc