What's the best way to do insert variables in a string in JavaScript? I'm guessing it's not this:
var coordinates = "x: " + x + ", y: " + y;
In Java, String
s are immutable and doing something like the above would unnecessarily create and throw away String
s. Ruby is similar and has a nice way of doing the above:
coordinates = "x: #{x}, y: #{y}"
Does something similar exist for JavaScript?