0

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
asked Apr 2, 2020 at 22:07
2
  • Does this answer your question? Executing Javascript from Python Commented Apr 3, 2020 at 0:22
  • @SuperStormer I am using python 3.8 and PyV8 is not in python 3.x. Commented Apr 3, 2020 at 0:30

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.