You have tried three ways. I have tried in JSP inside the script tag and below work for me fine except for the third 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));
The difference is if we assign value to a variable within single quotes or double quotes, it treated as a string otherwise number. If you assign value as <c:set name="x" value="23.35" /> then can access by '${x}'.
var temp = <%= x %>. If this is a JSP file, the value should be replaced before the JavaScript interpreter gets to it.