I am building a python application that needs to run some javascript code. I have node.js installed. I want to define a function in javascript and then be able to run it elsewhere in the program. Here is an example:
#My javascript function:
js_code = """
function add(a,b){return a+b};
"""
#Define js function here
myVar = add(3,4) #run the add function here
-
Does this answer your question? Executing Javascript from PythonSuperStormer– SuperStormer2020年04月03日 00:22:16 +00:00Commented Apr 3, 2020 at 0:22
-
@SuperStormer I am using python 3.8 and PyV8 is not in python 3.x.trigangle– trigangle2020年04月03日 00:30:57 +00:00Commented Apr 3, 2020 at 0:30
default