How to include images kept in static folder in JavaScript as variables in Django

Solution for How to include images kept in static folder in JavaScript as variables in Django
is Given Below:

how to do the image part here

I’m getting my data from a JSON data list. I can’t figure out how to include those image sources from the data inside the JavaScript ${variable} notation like others variables as shown in the figure. The images are kept in the static folder

Firstly take a div and set src image there and get the image source from the script:

<div id="image-source" src={% static 'your/image/path' %} style="display: none;"></div>

then in script:

var imagesrc = document.getElementById('image-source').getAttribute('src');