AV's Blog

Jupyter Notebooks with Python and JavaScript

August 06, 2018

For me, Jupyter Notebook is a great tool for studying. It lets me run snippets of code and add notes about the code. Right now, I use it for preparing for coding interviews. It’s perfect in reviewing Python.

A few months back, a friend of mine mentioned using Jupyter Notebooks with JavaScript. So now that I’ve been using it again after a while (I used it back when I was learning data analysis), I tried to figure out how to use JavaScript in it.

First, I found this plugin called PixieDust Node. I find it perfect for running both JavaScript and Python in the same notebook. To execute a JavaScript code, you have to import the module pixiedust_node first, and then use the magic %%node to run a JS code snippet. The scope of the code is only available in that same cell where the code is run. In other words, any variables you defined in that cell is not anymore accessible in the next cells.


The next one I found is IJavaScript, which is a “JavaScript kernel for the Jupyter Notebook”. It therefore only runs JavaScript, since it runs inside a Node.js session.


Installation is explained in the repo for it, and involves using pip and npm for all systems.