How do I concatenate a string with a variable?

前端 未结 5 1390
醉话见心
醉话见心 2020-11-22 16:26

So I am trying to make a string out of a string and a passed variable(which is a number). How do I do that?

I have something like this:

function AddB         


        
5条回答
  •  梦谈多话
    2020-11-22 17:24

    In javascript the "+" operator is used to add numbers or to concatenate strings. if one of the operands is a string "+" concatenates, and if it is only numbers it adds them.

    example:

    1+2+3 == 6
    "1"+2+3 == "123"
    

提交回复
热议问题