javascript - SyntaxError: missing variable name? -


i have ejs code create temp vector.

 <% var temp=[];    (i = 0; < his.length; i++) {          temp[i]=  his[i].temp; };%> 

the variable "his" comming server inside script tag have this.

var tempe = <%= temp; %> console.log(tempe);  

i got syntaxerror: missing variable name

what can do?

note: mozilla debugger shows tempe

tempe= 76,74,24,29,69,59,44` 

you need output array array...

var tempe = <%= temp; %> going browser tempe = 76,74,24,29,69,59,44 you're seeing in debugger. want is:

tempe = [76,74,24,29,69,59,44];  

which can doing this:

var tempe = <%-json.stringify(temp)%>; 

or less neatly, this:

var tempe = [<%= temp; %>]; 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -