string interpolation .... like perl

Giganews Newsgroups
Subject: string interpolation .... like perl
Posted by:  w i l l (willis_31_…
Date: Thu, 03 Jul 2003

I am beginning JavaScript, expect to see me in here a bit more over
the next few months :) I am currently writing some HTML with
JavaScript. As you know HTML has many double quotes ( " ) when
declaring attibute values, I know in some cases quotes are optional,
but I like them.

Here is something I've been playing with , it works, but in my
opinion, it's ulgy...

var myArray = new Array("blue","green","red");
for(var i = 0; i < myArray.length; i++) {
document.write("<input type=\"submit\" value=\"" + myArray[i] +"\"
onClick=\"document.bgColor='" + myArray[i] +"'\">");

Is there any way to mix javascript variables in with HTML without
having to excape all of the qoutes?

a perlish solution would be the qq operatior. but I know of nothing in
javascript. Is there anything?

perlish example...

document.write(qq` an example of " any text" ... `);


w i l l