socket.io client send data node js server

JavaScript
var socket = io.connect('http://localhost');
socket.emit('my other event', { my: 'data' });
//server side
io.sockets.on('connection', function (socket) {
  socket.on('my other event', function (data) {
    console.log(data);
  });
});
//sending data from the user via a socket.io
socket.on("test", function (data) {
    data.forEach(obj => {
        console.log("Yer : " + obj.yer + ", Lat : " + obj.lat + ", Long : " + obj.lng);
    })
});<script src="/socket.io/socket.io.js"></script>
<script>
  const socket = io();
</script>const socket = new WebSocket('ws://localhost:3000');socket.onopen(() => {  socket.send('Hello!');});socket.onmessage(data => {  console.log(data);});
Source

Also in JavaScript: