JavaScript parse variable in quote -


possible duplicate:
javascript variable inside string without concatenation - php

in php, double quotes has ability read variable, e.g.

"$foo" 

but in javascript, have use + read variable variable won't inside quote when read, e.g.

var foo='bar'; alert("the name's "+foo); 

so, there workaround or method this? using + time quite troublesome.

nope, that's not possible in javascript.

in javascript, variables turned string when put in single quotes or doubles quotes , can't parsed. in javascript everything inside quotes treated string.

even if write custom parser, have no way figure out if in quotes variable or string because variable named name can appear in string somewhere create naming collisions.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -