Working answers are already given but I want to add a check that acts as a fail-safe in case the flask variable is not available. When you use:
var myVariable = {{ flaskvar | tojson }};
if there is an error that causes the variable to be non existent, resulting errors may produce unexpected results. To avoid this:
{% if flaskvar is defined and flaskvar %}
var myVariable = {{ flaskvar | tojson }};
{% endif %}