Can I create an iPython laptop using JavaScript as the language in the cells?

I like IPython for explaining algorithms in python. But I want to do the same with javascript. Is it possible to write a notebook where I use javascript as a cell language?

+4
source share
1 answer

You can use the magic function %%javascriptto run javascript on an IPython laptop. For example, paste the following code into an IPython cell and run it. You should see the output in the javascript browser console.

%%javascript
console.log("Hello World!")

For global variables, you can add an attribute to the object windowsfor For example, in the cell, execute the following code:

%%javascript
window.myvar = 12;

javascript . .

%%javascript
console.log(myvar)

element , :

%%javascript
element.append(myvar)
+7

All Articles