In a real-time chat application, you need to implement a feature that notifies users when someone is typing a message. How would you accomplish this using JavaScript?

  • Use AJAX polling to check typing status
  • Use WebSocket to send typing status
  • Use oninput event listener
  • Use setTimeout and clearTimeout for delay
Using WebSocket allows real-time communication between clients and the server, making it ideal for notifying users when someone is typing. setTimeout and clearTimeout are more suitable for handling delays and timeouts, not real-time updates. AJAX polling introduces unnecessary overhead and delays. The oninput event listener is used for detecting input changes, not real-time status updates.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *