how react work

JavaScript
React creates a VIRTUAL DOM in memory.
Instead of manipulating the browser's DOM directly, 
React creates a virtual DOM in memory, 
where it does all the necessary manipulating, 
  before making the changes in the browser DOM.
then changes only what needs to be changed
Source

Also in JavaScript: