Determine ws event frame type.

To determine the websocket frame type you can use the following comparisons:

  • e.data instanceof ArrayBuffer
  • e.data instanceof Blob
  • typeof e.data === "string"

Links:

stackoverflow.com