How do I put variables inside javascript strings?

前端 未结 13 1089
感动是毒
感动是毒 2020-12-12 15:12
s = \'hello %s, how are you doing\' % (my_name)

That\'s how you do it in python. How can you do that in javascript/node.js?

13条回答
  •  醉梦人生
    2020-12-12 15:53

    Do that:

    s = 'hello ' + my_name + ', how are you doing'
    

    Update

    With ES6, you could also do this:

    s = `hello ${my_name}, how are you doing`
    

提交回复
热议问题