-3

Can you perform replacements on a string put in a variable? This won't work.

var obj = {a:1};
var a = '`${obj.a}`';

console.log(String.raw a);
C B
  • 12,482
  • 5
  • 36
  • 48

1 Answers1

2

I'm not too sure what you mean. Is the expected output 1?

If so, your string template literal is going to look like

var a = `${obj.a}`

instead of

var a = '`${obj.a}`'
g2jose
  • 1,367
  • 1
  • 9
  • 11