The traditional web was not designed for bidirectional communication. It was mostly designed as request/response paradigm where a client can only make a request to server and server can only respond to that request. To make things easy and faster, HTML5 introduced amazing WebSocket.
WebSocket is a low latency bi-directional persistent connection between server and client where both server and client can send messages to each other.
With help of WebSocket, we can easily write a chat application in Node.js by ws library. Make sure Node.JS is installed.