socket.emit in the developer console

Now, another cool thing about the console is that we have access to the variables created by our application; most notably the socket variable. This means that inside Google Chrome, in the developer console, we can call socket.emit and we emit whatever we like.

I can emit an action, createEmail, and I can pass in some data as the second argument, an object where I have a to attribute equal to julie@example.com. I have my other attributes too—something like text, which I can set equal to Hey:

socket.emit('createEmail', {to: 'julie@example.com', text: 'Hey'});

This is an example of how we can use the developer console to make debugging our app even easier. We can type a statement, hit enter, and it's going ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.