After experimenting with various methods, I found that using JSP inside the script tag worked well for me except for one way.
<% double x = 23.35; %>
var temp = <%=x%>;
console.log(temp);
console.log(typeof(temp));
var temp2 = '<%=x%>';
console.log(temp2);
console.log(typeof(temp2));
var temp3 = "<%=x%>";
console.log(temp3);
console.log(typeof(temp3));
I discovered that the key difference lies in how values are assigned to variables. When enclosed in single or double quotes, they are treated as strings, otherwise as numbers. Alternatively, assigning a value using
<c:set name="x" value="23.35" />
allows access through
'${x}'
.