Nowadays the term 'virtual DOM' introduced by React is very popular among developers. I just want to understand what is virtual DOM and the benefits of using it in place of simple DOM.
document.getElementById('container').style['background'] = "#ffffff";
Well Virtual DOM was not introduced by React but it is using Virtual DOM and provide us elements that can be helpful to create Virtual DOM. Virtual DOM is a programming technique where virtual UI is kept into memory and it is synced with DOM. React uses a library called 'ReactDOM' for the synchronization process.
Virtual DOM can also be called as an abstraction of real DOM. React do all the computations and update its Virtual DOM. This will skip the real DOM operations which is slow and browser-specific.
In React, we use React Elements to make our Virtual DOM. React Elements are immutable so these are fast and provide great performance when it comes to updating these elements and applying events.